Skip to content

Commit

Permalink
Zipkin exporter report instrumentation info (#1097)
Browse files Browse the repository at this point in the history
* Zipkin exporter report instrumentation info
  • Loading branch information
dengliming authored Sep 14, 2020
1 parent 12f51bc commit 6588a70
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions exporter/opentelemetry-exporter-zipkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
`port`, `protocol`, `endpoint`. This brings this implementation inline with other
implementations.
([#1064](https://github.com/open-telemetry/opentelemetry-python/pull/1064))
- Zipkin exporter report instrumentation info.
([#1097](https://github.com/open-telemetry/opentelemetry-python/pull/1097))

## Version 0.12b0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ def _translate_to_zipkin(self, spans: Sequence[Span]):
"annotations": _extract_annotations_from_events(span.events),
}

if span.instrumentation_info is not None:
zipkin_span["tags"][
"otel.instrumentation_library.name"
] = span.instrumentation_info.name
zipkin_span["tags"][
"otel.instrumentation_library.version"
] = span.instrumentation_info.version

if context.trace_flags.sampled:
zipkin_span["debug"] = True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from opentelemetry.sdk import trace
from opentelemetry.sdk.trace import Resource
from opentelemetry.sdk.trace.export import SpanExportResult
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
from opentelemetry.trace import TraceFlags


Expand Down Expand Up @@ -191,6 +192,9 @@ def test_export(self):
otel_spans[3].start(start_time=start_times[3])
otel_spans[3].resource = Resource({})
otel_spans[3].end(end_time=end_times[3])
otel_spans[3].instrumentation_info = InstrumentationInfo(
name="name", version="version"
)

service_name = "test-service"
local_endpoint = {"serviceName": service_name, "port": 9411}
Expand Down Expand Up @@ -252,7 +256,10 @@ def test_export(self):
"duration": durations[3] // 10 ** 3,
"localEndpoint": local_endpoint,
"kind": None,
"tags": {},
"tags": {
"otel.instrumentation_library.name": "name",
"otel.instrumentation_library.version": "version",
},
"annotations": None,
},
]
Expand Down

0 comments on commit 6588a70

Please sign in to comment.