-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkg/trace/api: add support for OpenTelemetry Span Links. #15767
Conversation
releasenotes/notes/apm-span-links-support-78478b81bf08e26f.yaml
Outdated
Show resolved
Hide resolved
….span_links' based on revised rfc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As requested by @dineshg13 , attaching a screenshot of the span link encoding from a test case. |
…oding hex-encoded strings. Additionally, update variable declarations to be idiomatic Go.
…n decoding hex-encoded strings.
…st all combinations of optional fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pre-approving because I don't feel strongly about my final comments and to unblock you from merging after potentially addressing them.
pkg/trace/api/otlp_test.go
Outdated
@@ -1274,6 +1397,138 @@ func trimSpaces(str string) string { | |||
return out.String() | |||
} | |||
|
|||
func makeSpanLinkSlice(traceId, spanId, traceState string, attrs map[string]string, dropped uint32) ptrace.SpanLinkSlice { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I usually think it's a good practice to test helper functions too. If it's a test helper, it doesn't mean it is reliable to work correctly 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was on the fence about this one since, if there were any problems with it, then TestMarshalSpanLinks
would likely fail but it certainly doesn't hurt to add some basic testing.
Done.
…to stable. This PR graduates feature gate `exporter.datadog.hostname.preview` to Stable. This is a follow up to [PR1](DataDog/opentelemetry-mapping-go#21) and [PR2](DataDog/datadog-agent#16159). **Note:** This PR pins a pseudoversion of `github.com/DataDog/datadog-agent/pkg/trace` in order to use take advantage of changes ([commit](DataDog/datadog-agent@8b27e87)) done in preparation of this PR. This pseudoversion also contains a change to add support for span links ([PR](DataDog/datadog-agent#15767)), which has been added to the changelog.
…to stable. (#20286) * exporter/datadogexporter: Graduate exporter.datadog.hostname.preview to stable. This PR graduates feature gate `exporter.datadog.hostname.preview` to Stable. This is a follow up to [PR1](DataDog/opentelemetry-mapping-go#21) and [PR2](DataDog/datadog-agent#16159). **Note:** This PR pins a pseudoversion of `github.com/DataDog/datadog-agent/pkg/trace` in order to use take advantage of changes ([commit](DataDog/datadog-agent@8b27e87)) done in preparation of this PR. This pseudoversion also contains a change to add support for span links ([PR](DataDog/datadog-agent#15767)), which has been added to the changelog. * add PR # to changelog * run make gotidy * Update .chloggen/datadog-exporter-span-links-support.yaml Co-authored-by: Pablo Baeyens <[email protected]> --------- Co-authored-by: Pablo Baeyens <[email protected]>
What does this PR do?
Adds support for OpenTelemetry span links to the Trace Agent.
During the conversion from OTLP to the Datadog trace protobuf, any span with span links will have the span links added to the metadata with the key '_dd.span_links'.
Motivation
This change is part of an ongoing effort to support OpenTelemetry Span Links at Datadog.
Additional Notes
Span links will be JSON encoded as:
{ "trace_id":
trace_id
, "span_id":span_id
[,"trace_state":trace_state
][,"attributes":{ (
key
:value
)+ }] [,"dropped_attributes_count":uint64] }where
trace_id
&span_id
are hex-encoded unsigned ints,trace_state
is the W3C TraceState encoding as a string, andkey
&value
are arbitrary strings.Note that "trace_state", "attributes", and "dropped_attributes_count" are optional and will only be present if they contain non-empty/non-zero values.
Possible Drawbacks / Trade-offs
This change only affects the OTel path and only for spans that contain span links so it will only impact a small percentage of spans. The main possible drawback will be the added processing overhead (converting span links to JSON) and the added metadata.
Describe how to test/QA your changes
Send a span with span links from an OpenTelemetry service and check the resulting converted span has the links in the metadata.
Reviewer's Checklist
Triage
milestone is set.major_change
label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.changelog/no-changelog
label has been applied.qa/skip-qa
label is not applied.team/..
label has been applied, indicating the team(s) that should QA this change.need-change/operator
andneed-change/helm
labels have been applied.k8s/<min-version>
label, indicating the lowest Kubernetes version compatible with this feature.