Skip to content

Commit 03473b0

Browse files
committed
fix(otlp): align with upstream pb definition
1 parent faf8868 commit 03473b0

File tree

4 files changed

+63
-63
lines changed

4 files changed

+63
-63
lines changed

exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/trace_exporter/__init__.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
from opentelemetry.proto.collector.trace.v1.trace_service_pb2_grpc import (
3333
TraceServiceStub,
3434
)
35-
from opentelemetry.proto.common.v1.common_pb2 import InstrumentationLibrary
35+
from opentelemetry.proto.common.v1.common_pb2 import InstrumentationScope
3636
from opentelemetry.proto.trace.v1.trace_pb2 import (
37-
InstrumentationLibrarySpans,
37+
ScopeSpans,
3838
ResourceSpans,
3939
)
4040
from opentelemetry.proto.trace.v1.trace_pb2 import Span as CollectorSpan
@@ -217,42 +217,42 @@ def _translate_data(
217217
) -> ExportTraceServiceRequest:
218218
# pylint: disable=attribute-defined-outside-init
219219

220-
sdk_resource_instrumentation_library_spans = {}
220+
sdk_resource_scope_spans = {}
221221

222222
for sdk_span in data:
223-
instrumentation_library_spans_map = (
224-
sdk_resource_instrumentation_library_spans.get(
223+
scope_spans_map = (
224+
sdk_resource_scope_spans.get(
225225
sdk_span.resource, {}
226226
)
227227
)
228228
# If we haven't seen the Resource yet, add it to the map
229-
if not instrumentation_library_spans_map:
230-
sdk_resource_instrumentation_library_spans[
229+
if not scope_spans_map:
230+
sdk_resource_scope_spans[
231231
sdk_span.resource
232-
] = instrumentation_library_spans_map
233-
instrumentation_library_spans = (
234-
instrumentation_library_spans_map.get(
232+
] = scope_spans_map
233+
scope_spans = (
234+
scope_spans_map.get(
235235
sdk_span.instrumentation_info
236236
)
237237
)
238238
# If we haven't seen the InstrumentationInfo for this Resource yet, add it to the map
239-
if not instrumentation_library_spans:
239+
if not scope_spans:
240240
if sdk_span.instrumentation_info is not None:
241-
instrumentation_library_spans_map[
241+
scope_spans_map[
242242
sdk_span.instrumentation_info
243-
] = InstrumentationLibrarySpans(
244-
instrumentation_library=InstrumentationLibrary(
243+
] = ScopeSpans(
244+
scope=InstrumentationScope(
245245
name=sdk_span.instrumentation_info.name,
246246
version=sdk_span.instrumentation_info.version,
247247
)
248248
)
249249
else:
250250
# If no InstrumentationInfo, store in None key
251-
instrumentation_library_spans_map[
251+
scope_spans_map[
252252
sdk_span.instrumentation_info
253-
] = InstrumentationLibrarySpans()
254-
instrumentation_library_spans = (
255-
instrumentation_library_spans_map.get(
253+
] = ScopeSpans()
254+
scope_spans = (
255+
scope_spans_map.get(
256256
sdk_span.instrumentation_info
257257
)
258258
)
@@ -289,13 +289,13 @@ def _translate_data(
289289
f"SPAN_KIND_{sdk_span.kind.name}",
290290
)
291291

292-
instrumentation_library_spans.spans.append(
292+
scope_spans.spans.append(
293293
CollectorSpan(**self._collector_kwargs)
294294
)
295295

296296
return ExportTraceServiceRequest(
297297
resource_spans=get_resource_data(
298-
sdk_resource_instrumentation_library_spans,
298+
sdk_resource_scope_spans,
299299
ResourceSpans,
300300
"spans",
301301
)

exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_trace_exporter.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
from opentelemetry.proto.common.v1.common_pb2 import (
4141
AnyValue,
4242
ArrayValue,
43-
InstrumentationLibrary,
43+
InstrumentationScope,
4444
KeyValue,
4545
)
4646
from opentelemetry.proto.resource.v1.resource_pb2 import (
4747
Resource as OTLPResource,
4848
)
4949
from opentelemetry.proto.trace.v1.trace_pb2 import (
50-
InstrumentationLibrarySpans,
50+
ScopeSpans,
5151
ResourceSpans,
5252
)
5353
from opentelemetry.proto.trace.v1.trace_pb2 import Span as OTLPSpan
@@ -493,9 +493,9 @@ def test_translate_spans(self):
493493
),
494494
]
495495
),
496-
instrumentation_library_spans=[
497-
InstrumentationLibrarySpans(
498-
instrumentation_library=InstrumentationLibrary(
496+
scope_spans=[
497+
ScopeSpans(
498+
scope=InstrumentationScope(
499499
name="name", version="version"
500500
),
501501
spans=[
@@ -595,9 +595,9 @@ def test_translate_spans_multi(self):
595595
),
596596
]
597597
),
598-
instrumentation_library_spans=[
599-
InstrumentationLibrarySpans(
600-
instrumentation_library=InstrumentationLibrary(
598+
scope_spans=[
599+
ScopeSpans(
600+
scope=InstrumentationScope(
601601
name="name", version="version"
602602
),
603603
spans=[
@@ -677,8 +677,8 @@ def test_translate_spans_multi(self):
677677
)
678678
],
679679
),
680-
InstrumentationLibrarySpans(
681-
instrumentation_library=InstrumentationLibrary(
680+
ScopeSpans(
681+
scope=InstrumentationScope(
682682
name="name2", version="version2"
683683
),
684684
spans=[
@@ -717,9 +717,9 @@ def test_translate_spans_multi(self):
717717
),
718718
]
719719
),
720-
instrumentation_library_spans=[
721-
InstrumentationLibrarySpans(
722-
instrumentation_library=InstrumentationLibrary(
720+
scope_spans=[
721+
ScopeSpans(
722+
scope=InstrumentationScope(
723723
name="name", version="version"
724724
),
725725
spans=[
@@ -765,7 +765,7 @@ def _check_translated_status(
765765
):
766766
status = (
767767
translated.resource_spans[0]
768-
.instrumentation_library_spans[0]
768+
.scope_spans[0]
769769
.spans[0]
770770
.status
771771
)
@@ -861,36 +861,36 @@ def test_dropped_values(self):
861861
self.assertEqual(
862862
1,
863863
translated.resource_spans[0]
864-
.instrumentation_library_spans[0]
864+
.scope_spans[0]
865865
.spans[0]
866866
.dropped_links_count,
867867
)
868868
self.assertEqual(
869869
2,
870870
translated.resource_spans[0]
871-
.instrumentation_library_spans[0]
871+
.scope_spans[0]
872872
.spans[0]
873873
.dropped_attributes_count,
874874
)
875875
self.assertEqual(
876876
3,
877877
translated.resource_spans[0]
878-
.instrumentation_library_spans[0]
878+
.scope_spans[0]
879879
.spans[0]
880880
.dropped_events_count,
881881
)
882882
self.assertEqual(
883883
2,
884884
translated.resource_spans[0]
885-
.instrumentation_library_spans[0]
885+
.scope_spans[0]
886886
.spans[0]
887887
.links[0]
888888
.dropped_attributes_count,
889889
)
890890
self.assertEqual(
891891
2,
892892
translated.resource_spans[0]
893-
.instrumentation_library_spans[0]
893+
.scope_spans[0]
894894
.spans[0]
895895
.events[0]
896896
.dropped_attributes_count,

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/encoder/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
ArrayValue as PB2ArrayValue,
2525
)
2626
from opentelemetry.proto.common.v1.common_pb2 import (
27-
InstrumentationLibrary as PB2InstrumentationLibrary,
27+
InstrumentationScope as PB2InstrumentationScope,
2828
)
2929
from opentelemetry.proto.common.v1.common_pb2 import KeyValue as PB2KeyValue
3030
from opentelemetry.proto.resource.v1.resource_pb2 import (
3131
Resource as PB2Resource,
3232
)
3333
from opentelemetry.proto.trace.v1.trace_pb2 import (
34-
InstrumentationLibrarySpans as PB2InstrumentationLibrarySpans,
34+
ScopeSpans as PB2ScopeSpans,
3535
)
3636
from opentelemetry.proto.trace.v1.trace_pb2 import (
3737
ResourceSpans as PB2ResourceSpans,
@@ -79,7 +79,7 @@ def _encode_resource_spans(
7979
# We need to inspect the spans and group + structure them as:
8080
#
8181
# Resource
82-
# Instrumentation Library
82+
# Scope Spans
8383
# Spans
8484
#
8585
# First loop organizes the SDK spans in this structure. Protobuf messages
@@ -110,20 +110,20 @@ def _encode_resource_spans(
110110
pb2_resource_spans = []
111111

112112
for sdk_resource, sdk_instrumentations in sdk_resource_spans.items():
113-
instrumentation_library_spans = []
113+
scope_spans = []
114114
for sdk_instrumentation, pb2_spans in sdk_instrumentations.items():
115-
instrumentation_library_spans.append(
116-
PB2InstrumentationLibrarySpans(
117-
instrumentation_library=(
118-
_encode_instrumentation_library(sdk_instrumentation)
115+
scope_spans.append(
116+
PB2ScopeSpans(
117+
scope=(
118+
_encode_instrumentation_scope(sdk_instrumentation)
119119
),
120120
spans=pb2_spans,
121121
)
122122
)
123123
pb2_resource_spans.append(
124124
PB2ResourceSpans(
125125
resource=_encode_resource(sdk_resource),
126-
instrumentation_library_spans=instrumentation_library_spans,
126+
scope_spans=scope_spans,
127127
)
128128
)
129129

@@ -245,17 +245,17 @@ def _encode_resource(resource: Resource) -> PB2Resource:
245245
return pb2_resource
246246

247247

248-
def _encode_instrumentation_library(
248+
def _encode_instrumentation_scope(
249249
instrumentation_info: InstrumentationInfo,
250-
) -> PB2InstrumentationLibrary:
250+
) -> PB2InstrumentationScope:
251251
if instrumentation_info is None:
252-
pb2_instrumentation_library = PB2InstrumentationLibrary()
252+
pb2_instrumentation_scope = PB2InstrumentationScope()
253253
else:
254-
pb2_instrumentation_library = PB2InstrumentationLibrary(
254+
pb2_instrumentation_scope = PB2InstrumentationScope(
255255
name=instrumentation_info.name,
256256
version=instrumentation_info.version,
257257
)
258-
return pb2_instrumentation_library
258+
return pb2_instrumentation_scope
259259

260260

261261
def _encode_value(value: Any) -> PB2AnyValue:

exporter/opentelemetry-exporter-otlp-proto-http/tests/test_protobuf_encoder.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
)
3030
from opentelemetry.proto.common.v1.common_pb2 import AnyValue as PB2AnyValue
3131
from opentelemetry.proto.common.v1.common_pb2 import (
32-
InstrumentationLibrary as PB2InstrumentationLibrary,
32+
InstrumentationScope as PB2InstrumentationScope,
3333
)
3434
from opentelemetry.proto.common.v1.common_pb2 import KeyValue as PB2KeyValue
3535
from opentelemetry.proto.resource.v1.resource_pb2 import (
3636
Resource as PB2Resource,
3737
)
3838
from opentelemetry.proto.trace.v1.trace_pb2 import (
39-
InstrumentationLibrarySpans as PB2InstrumentationLibrarySpans,
39+
ScopeSpans as PB2ScopeSpans,
4040
)
4141
from opentelemetry.proto.trace.v1.trace_pb2 import (
4242
ResourceSpans as PB2ResourceSpans,
@@ -178,9 +178,9 @@ def get_exhaustive_test_spans(
178178
resource_spans=[
179179
PB2ResourceSpans(
180180
resource=PB2Resource(),
181-
instrumentation_library_spans=[
182-
PB2InstrumentationLibrarySpans(
183-
instrumentation_library=PB2InstrumentationLibrary(),
181+
scope_spans=[
182+
PB2ScopeSpans(
183+
scope=PB2InstrumentationScope(),
184184
spans=[
185185
PB2SPan(
186186
trace_id=trace_id,
@@ -274,8 +274,8 @@ def get_exhaustive_test_spans(
274274
)
275275
],
276276
),
277-
PB2InstrumentationLibrarySpans(
278-
instrumentation_library=PB2InstrumentationLibrary(
277+
PB2ScopeSpans(
278+
scope=PB2InstrumentationScope(
279279
name="name",
280280
version="version",
281281
),
@@ -313,9 +313,9 @@ def get_exhaustive_test_spans(
313313
)
314314
]
315315
),
316-
instrumentation_library_spans=[
317-
PB2InstrumentationLibrarySpans(
318-
instrumentation_library=PB2InstrumentationLibrary(),
316+
scope_spans=[
317+
PB2ScopeSpans(
318+
scope=PB2InstrumentationScope(),
319319
spans=[
320320
PB2SPan(
321321
trace_id=trace_id,

0 commit comments

Comments
 (0)