Skip to content

Commit 3e17ef9

Browse files
dmathieupellaredXSAM
authored
Allow relying on InstrumentationScope in SpanStub and fix remaining deprecation issues (#5627)
Rather than the deprecated InstrumentationLibrary This is a replacement for #3104, as after this, there is no usage of `instrumentation.Library` within the SDK anymore. --------- Co-authored-by: Robert Pająk <[email protected]> Co-authored-by: Sam Xie <[email protected]>
1 parent d4b5396 commit 3e17ef9

File tree

12 files changed

+49
-33
lines changed

12 files changed

+49
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1515
This new module contains an OTLP exporter that transmits log telemetry using gRPC.
1616
This module is unstable and breaking changes may be introduced.
1717
See our [versioning policy](VERSIONING.md) for more information about these stability guarantees. (#5629)
18+
- Add `InstrumentationScope` field to `SpanStub` in `go.opentelemetry.io/otel/sdk/trace/tracetest`, as a replacement for the deprecated `InstrumentationLibrary`. (#5627)
1819

1920
### Fixed
2021

bridge/opencensus/trace_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ func TestNewTraceBridge(t *testing.T) {
2323
gotSpans := exporter.GetSpans()
2424
require.Len(t, gotSpans, 1)
2525
gotSpan := gotSpans[0]
26-
assert.Equal(t, gotSpan.InstrumentationLibrary.Name, scopeName)
27-
assert.Equal(t, gotSpan.InstrumentationLibrary.Version, Version())
26+
assert.Equal(t, gotSpan.InstrumentationScope.Name, scopeName)
27+
assert.Equal(t, gotSpan.InstrumentationScope.Version, Version())
2828
}

exporters/otlp/otlptrace/internal/tracetransform/span_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func TestSpanData(t *testing.T) {
280280
attribute.Int64("rk2", 5),
281281
attribute.StringSlice("rk3", []string{"sv1", "sv2"}),
282282
),
283-
InstrumentationLibrary: instrumentation.Scope{
283+
InstrumentationScope: instrumentation.Scope{
284284
Name: "go.opentelemetry.io/test/otel",
285285
Version: "v0.0.1",
286286
SchemaURL: semconv.SchemaURL,
@@ -316,8 +316,8 @@ func TestSpanData(t *testing.T) {
316316
assert.Equal(t, got[0].SchemaUrl, spanData.Resource.SchemaURL())
317317
scopeSpans := got[0].GetScopeSpans()
318318
require.Len(t, scopeSpans, 1)
319-
assert.Equal(t, scopeSpans[0].SchemaUrl, spanData.InstrumentationLibrary.SchemaURL)
320-
assert.Equal(t, scopeSpans[0].GetScope(), InstrumentationScope(spanData.InstrumentationLibrary))
319+
assert.Equal(t, scopeSpans[0].SchemaUrl, spanData.InstrumentationScope.SchemaURL)
320+
assert.Equal(t, scopeSpans[0].GetScope(), InstrumentationScope(spanData.InstrumentationScope))
321321
require.Len(t, scopeSpans[0].Spans, 1)
322322
actualSpan := scopeSpans[0].Spans[0]
323323

exporters/otlp/otlptrace/otlptracegrpc/internal/otlptracetest/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func SingleReadOnlySpan() []tracesdk.ReadOnlySpan {
4646
DroppedLinks: 0,
4747
ChildSpanCount: 0,
4848
Resource: resource.NewSchemaless(attribute.String("a", "b")),
49-
InstrumentationLibrary: instrumentation.Library{
49+
InstrumentationScope: instrumentation.Scope{
5050
Name: "bar",
5151
Version: "0.0.0",
5252
},

exporters/otlp/otlptrace/otlptracehttp/internal/otlptracetest/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func SingleReadOnlySpan() []tracesdk.ReadOnlySpan {
4646
DroppedLinks: 0,
4747
ChildSpanCount: 0,
4848
Resource: resource.NewSchemaless(attribute.String("a", "b")),
49-
InstrumentationLibrary: instrumentation.Library{
49+
InstrumentationScope: instrumentation.Scope{
5050
Name: "bar",
5151
Version: "0.0.0",
5252
},

exporters/stdout/stdouttrace/trace_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ func expectedJSON(now time.Time) string {
186186
}
187187
}
188188
],
189+
"InstrumentationScope": {
190+
"Name": "",
191+
"Version": "",
192+
"SchemaURL": ""
193+
},
189194
"InstrumentationLibrary": {
190195
"Name": "",
191196
"Version": "",

exporters/zipkin/model_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,15 +1015,15 @@ func TestTagsTransformation(t *testing.T) {
10151015
{
10161016
name: "instrLib-empty",
10171017
data: tracetest.SpanStub{
1018-
InstrumentationLibrary: instrumentation.Library{},
1018+
InstrumentationScope: instrumentation.Scope{},
10191019
},
10201020
want: nil,
10211021
},
10221022
{
10231023
name: "instrLib-noversion",
10241024
data: tracetest.SpanStub{
10251025
Attributes: []attribute.KeyValue{},
1026-
InstrumentationLibrary: instrumentation.Library{
1026+
InstrumentationScope: instrumentation.Scope{
10271027
Name: instrLibName,
10281028
},
10291029
},
@@ -1035,7 +1035,7 @@ func TestTagsTransformation(t *testing.T) {
10351035
name: "instrLib-with-version",
10361036
data: tracetest.SpanStub{
10371037
Attributes: []attribute.KeyValue{},
1038-
InstrumentationLibrary: instrumentation.Library{
1038+
InstrumentationScope: instrumentation.Scope{
10391039
Name: instrLibName,
10401040
Version: instrLibVersion,
10411041
},

internal/shared/otlp/otlptrace/otlptracetest/data.go.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func SingleReadOnlySpan() []tracesdk.ReadOnlySpan {
4646
DroppedLinks: 0,
4747
ChildSpanCount: 0,
4848
Resource: resource.NewSchemaless(attribute.String("a", "b")),
49-
InstrumentationLibrary: instrumentation.Library{
49+
InstrumentationScope: instrumentation.Scope{
5050
Name: "bar",
5151
Version: "0.0.0",
5252
},

sdk/instrumentation/library.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
package instrumentation // import "go.opentelemetry.io/otel/sdk/instrumentation"
55

66
// Library represents the instrumentation library.
7-
// Deprecated: please use Scope instead.
7+
//
8+
// Deprecated: use [Scope] instead.
89
type Library = Scope

sdk/trace/snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (s snapshot) InstrumentationScope() instrumentation.Scope {
9999

100100
// InstrumentationLibrary returns information about the instrumentation
101101
// library that created the span.
102-
func (s snapshot) InstrumentationLibrary() instrumentation.Library {
102+
func (s snapshot) InstrumentationLibrary() instrumentation.Library { //nolint:staticcheck // This method needs to be define for backwards compatibility
103103
return s.instrumentationScope
104104
}
105105

0 commit comments

Comments
 (0)