diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f3d6b333ac..b445c3fc4d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ 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)) diff --git a/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/translate/__init__.py b/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/translate/__init__.py index 778296a917c..e644e213603 100644 --- a/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/translate/__init__.py +++ b/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/translate/__init__.py @@ -318,10 +318,18 @@ def _extract_tags( def _extract_refs( self, span: ReadableSpan ) -> Optional[Sequence[model_pb2.SpanRef]]: - if not span.links: - return None refs = [] + if span.parent: + ctx = span.get_span_context() + parent_id = span.parent.span_id + parent_ref = model_pb2.SpanRef( + ref_type=model_pb2.SpanRefType.CHILD_OF, + trace_id=_trace_id_to_bytes(ctx.trace_id), + span_id=_span_id_to_bytes(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-proto-grpc/tests/test_jaeger_exporter_protobuf.py b/exporter/opentelemetry-exporter-jaeger-proto-grpc/tests/test_jaeger_exporter_protobuf.py index 99b3f093cb8..383e33d0f16 100644 --- a/exporter/opentelemetry-exporter-jaeger-proto-grpc/tests/test_jaeger_exporter_protobuf.py +++ b/exporter/opentelemetry-exporter-jaeger-proto-grpc/tests/test_jaeger_exporter_protobuf.py @@ -287,11 +287,16 @@ def test_translate_to_jaeger(self): ), ], references=[ + model_pb2.SpanRef( + ref_type=model_pb2.SpanRefType.CHILD_OF, + trace_id=pb_translator._trace_id_to_bytes(trace_id), + span_id=pb_translator._span_id_to_bytes(parent_id), + ), model_pb2.SpanRef( ref_type=model_pb2.SpanRefType.FOLLOWS_FROM, trace_id=pb_translator._trace_id_to_bytes(trace_id), span_id=pb_translator._span_id_to_bytes(other_id), - ) + ), ], logs=[ model_pb2.Log(