Skip to content

Conversation

@lahsivjar
Copy link
Contributor

@lahsivjar lahsivjar commented Jul 17, 2024

Checks if parent span is remote to decide the nature of the OTel span (elastic txn or span).

Follow-up for #46 (to be merged after)
Related to: https://github.com/elastic/opentelemetry-dev/issues/304

Comment on lines +273 to 284
flags := tracepb.SpanFlags(span.Flags())
switch {
case span.ParentSpanID().IsEmpty():
return true
case (flags & tracepb.SpanFlags_SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) == 0:
// span parent is unknown, fall back to span kind
return span.Kind() == ptrace.SpanKindServer || span.Kind() == ptrace.SpanKindConsumer
case (flags & tracepb.SpanFlags_SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0:
// span parent is remote
return true
}
return false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thank you!

@lahsivjar lahsivjar force-pushed the enrichment-remotespan branch from fe1da3a to 8cfb0d1 Compare July 18, 2024 08:40
@lahsivjar lahsivjar marked this pull request as ready for review July 18, 2024 08:40
@lahsivjar lahsivjar requested a review from a team as a code owner July 18, 2024 08:40
@lahsivjar lahsivjar requested a review from axw July 18, 2024 08:41
Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo! Thank you, so glad to see this after all these years.

@lahsivjar lahsivjar merged commit 56f9935 into elastic:main Jul 18, 2024
@lahsivjar lahsivjar deleted the enrichment-remotespan branch July 18, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants