Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instrumentation info to exported spans #1095

Merged
merged 4 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions exporter/opentelemetry-exporter-otlp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Add instrumentation info to exported spans
([#1095](https://github.com/open-telemetry/opentelemetry-python/pull/1095))
- Add metric OTLP exporter
([#835](https://github.com/open-telemetry/opentelemetry-python/pull/835))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from opentelemetry.proto.collector.trace.v1.trace_service_pb2_grpc import (
TraceServiceStub,
)
from opentelemetry.proto.common.v1.common_pb2 import InstrumentationLibrary
from opentelemetry.proto.trace.v1.trace_pb2 import (
InstrumentationLibrarySpans,
ResourceSpans,
Expand Down Expand Up @@ -168,9 +169,22 @@ def _translate_data(self, data) -> ExportTraceServiceRequest:
if sdk_span.resource not in (
sdk_resource_instrumentation_library_spans.keys()
):
if sdk_span.instrumentation_info is not None:
instrumentation_library_spans = InstrumentationLibrarySpans(
instrumentation_library=InstrumentationLibrary(
name=sdk_span.instrumentation_info.name,
version=sdk_span.instrumentation_info.version,
)
)

else:
instrumentation_library_spans = (
InstrumentationLibrarySpans()
)

sdk_resource_instrumentation_library_spans[
sdk_span.resource
] = InstrumentationLibrarySpans()
] = instrumentation_library_spans

self._collector_span_kwargs = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
TraceServiceServicer,
add_TraceServiceServicer_to_server,
)
from opentelemetry.proto.common.v1.common_pb2 import AnyValue, KeyValue
from opentelemetry.proto.common.v1.common_pb2 import (
AnyValue,
InstrumentationLibrary,
KeyValue,
)
from opentelemetry.proto.resource.v1.resource_pb2 import (
Resource as CollectorResource,
)
Expand All @@ -46,6 +50,7 @@
SimpleExportSpanProcessor,
SpanExportResult,
)
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
from opentelemetry.trace import SpanKind


Expand Down Expand Up @@ -142,6 +147,9 @@ def setUp(self):
}
)
],
instrumentation_info=InstrumentationInfo(
name="name", version="version"
),
)

self.span.start()
Expand Down Expand Up @@ -209,6 +217,9 @@ def test_translate_spans(self):
),
instrumentation_library_spans=[
InstrumentationLibrarySpans(
instrumentation_library=InstrumentationLibrary(
name="name", version="version"
),
spans=[
CollectorSpan(
# pylint: disable=no-member
Expand Down Expand Up @@ -282,7 +293,7 @@ def test_translate_spans(self):
)
],
)
]
],
)
],
),
Expand Down