Skip to content

Commit 813c485

Browse files
committed
allow relying on InstrumentationScope in SpanStub
rather than the deprecated InstrumentationLibrary
1 parent e3892f0 commit 813c485

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

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/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/trace/tracetest/span.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type SpanStub struct {
6060
DroppedLinks int
6161
ChildSpanCount int
6262
Resource *resource.Resource
63+
InstrumentationScope instrumentation.Scope
6364
InstrumentationLibrary instrumentation.Library
6465
}
6566

@@ -85,12 +86,18 @@ func SpanStubFromReadOnlySpan(ro tracesdk.ReadOnlySpan) SpanStub {
8586
DroppedLinks: ro.DroppedLinks(),
8687
ChildSpanCount: ro.ChildSpanCount(),
8788
Resource: ro.Resource(),
89+
InstrumentationScope: ro.InstrumentationScope(),
8890
InstrumentationLibrary: ro.InstrumentationScope(),
8991
}
9092
}
9193

9294
// Snapshot returns a read-only copy of the SpanStub.
9395
func (s SpanStub) Snapshot() tracesdk.ReadOnlySpan {
96+
scopeOrLibrary := s.InstrumentationScope
97+
if scopeOrLibrary.Name == "" && scopeOrLibrary.Version == "" && scopeOrLibrary.SchemaURL == "" {
98+
scopeOrLibrary = s.InstrumentationLibrary
99+
}
100+
94101
return spanSnapshot{
95102
name: s.Name,
96103
spanContext: s.SpanContext,
@@ -107,7 +114,7 @@ func (s SpanStub) Snapshot() tracesdk.ReadOnlySpan {
107114
droppedLinks: s.DroppedLinks,
108115
childSpanCount: s.ChildSpanCount,
109116
resource: s.Resource,
110-
instrumentationScope: s.InstrumentationLibrary,
117+
instrumentationScope: scopeOrLibrary,
111118
}
112119
}
113120

0 commit comments

Comments
 (0)