From 21fe6a822471b10ccf4ec3cff5a84949ed3adde5 Mon Sep 17 00:00:00 2001 From: Kristian Larsson Date: Mon, 3 May 2021 22:13:42 +0200 Subject: [PATCH] Include parent span in Jaeger gRPC export This extracts the parent span and adds it as a CHILD_OF reference in the gRPC export, so that we get the expected hierarchy of spans. --- .../exporter/jaeger/proto/grpc/translate/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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