From 3f5e8eba8ffc660d733f9b870aa915e3bf293820 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Mon, 10 May 2021 13:47:57 -0700 Subject: [PATCH 1/3] Include parent span in Jaeger thrift export --- CHANGELOG.md | 2 ++ .../exporter/jaeger/thrift/translate/__init__.py | 12 ++++++++++-- .../tests/test_jaeger_exporter_thrift.py | 10 +++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d9bf3e926..bd49b23d304 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1810](https://github.com/open-telemetry/opentelemetry-python/pull/1810)) - Fixed inconsistency in parent_id formatting from the ConsoleSpanExporter ([#1833](https://github.com/open-telemetry/opentelemetry-python/pull/1833)) +- Include span parent in Jaeger thrift export as `CHILD_OF` reference + ([#1835])(https://github.com/open-telemetry/opentelemetry-python/pull/1835) ### Removed - Moved `opentelemetry-instrumentation` to contrib repository. diff --git a/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/translate/__init__.py b/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/translate/__init__.py index c48c8bde8f3..24816ac0020 100644 --- a/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/translate/__init__.py +++ b/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/translate/__init__.py @@ -231,10 +231,18 @@ def _extract_tags(self, span: ReadableSpan) -> Sequence[TCollector.Tag]: def _extract_refs( self, span: ReadableSpan ) -> Optional[Sequence[TCollector.SpanRef]]: - if not span.links: - return None refs = [] + if span.parent: + ctx = span.get_span_context() + parent_id = span.parent.span_id + parent_ref = TCollector.SpanRef( + refType=TCollector.SpanRefType.CHILD_OF, + traceIdHigh=_get_trace_id_high(ctx.trace_id), + traceIdLow=_get_trace_id_low(ctx.trace_id), + spanId=_convert_int_to_i64(parent_id), + ) + refs.append(parent_ref) for link in span.links: trace_id = link.context.trace_id span_id = link.context.span_id diff --git a/exporter/opentelemetry-exporter-jaeger-thrift/tests/test_jaeger_exporter_thrift.py b/exporter/opentelemetry-exporter-jaeger-thrift/tests/test_jaeger_exporter_thrift.py index 9c1773d4fad..45ff30a461f 100644 --- a/exporter/opentelemetry-exporter-jaeger-thrift/tests/test_jaeger_exporter_thrift.py +++ b/exporter/opentelemetry-exporter-jaeger-thrift/tests/test_jaeger_exporter_thrift.py @@ -369,12 +369,18 @@ def test_translate_to_jaeger(self): ), ], references=[ + jaeger.SpanRef( + refType=jaeger.SpanRefType.CHILD_OF, + traceIdHigh=trace_id_high, + traceIdLow=trace_id_low, + spanId=parent_id, + ), jaeger.SpanRef( refType=jaeger.SpanRefType.FOLLOWS_FROM, traceIdHigh=trace_id_high, traceIdLow=trace_id_low, spanId=other_id, - ) + ), ], logs=[ jaeger.Log( @@ -414,6 +420,7 @@ def test_translate_to_jaeger(self): duration=durations[1] // 10 ** 3, flags=0, tags=default_tags, + references=[], ), jaeger.Span( operationName=span_names[2], @@ -446,6 +453,7 @@ def test_translate_to_jaeger(self): vStr="version", ), ], + references=[], ), ] From 30c22d7075ffc30165b1f8244c41d31f28774b39 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Mon, 10 May 2021 13:50:48 -0700 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd49b23d304..ae381a845d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed inconsistency in parent_id formatting from the ConsoleSpanExporter ([#1833](https://github.com/open-telemetry/opentelemetry-python/pull/1833)) - Include span parent in Jaeger thrift export as `CHILD_OF` reference - ([#1835])(https://github.com/open-telemetry/opentelemetry-python/pull/1835) + ([#1836])(https://github.com/open-telemetry/opentelemetry-python/pull/1836) ### Removed - Moved `opentelemetry-instrumentation` to contrib repository. From e766f9d59bcb0f2bcf58467bfd3f2781bb48096b Mon Sep 17 00:00:00 2001 From: alrex Date: Mon, 10 May 2021 14:40:19 -0700 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b6076a0355..659caf4093b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.1.0...HEAD) -### Changed -- Include span parent in Jaeger gRPC export as `CHILD_OF` reference - ([#1809])(https://github.com/open-telemetry/opentelemetry-python/pull/1809) - ### Added - Added example for running Django with auto instrumentation. ([#1803](https://github.com/open-telemetry/opentelemetry-python/pull/1803)) @@ -28,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1810](https://github.com/open-telemetry/opentelemetry-python/pull/1810)) - Fixed inconsistency in parent_id formatting from the ConsoleSpanExporter ([#1833](https://github.com/open-telemetry/opentelemetry-python/pull/1833)) +- Include span parent in Jaeger gRPC export as `CHILD_OF` reference + ([#1809])(https://github.com/open-telemetry/opentelemetry-python/pull/1809) - Include span parent in Jaeger thrift export as `CHILD_OF` reference ([#1836])(https://github.com/open-telemetry/opentelemetry-python/pull/1836)