-
Notifications
You must be signed in to change notification settings - Fork 445
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
contrib/internal/httptrace: add support for inferred proxy spans #3052
Conversation
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.
Needs a bit of cleanup and logging for prod but logically looks good. Going to request @wantsui to look at it as well to confirm the span information is relatively similar as in dd-trace-js.
BenchmarksBenchmark execution time: 2025-01-22 22:12:35 Comparing candidate commit 39087f1 in PR branch Found 0 performance improvements and 3 performance regressions! Performance is the same for 55 metrics, 1 unstable metrics. scenario:BenchmarkStartRequestSpan-24
|
Let's also make sure that we test that our inferred span matches the behavior of the parent span by asserting things like that status code are the same |
…W spans via headers Function checks for existence of AWS APIGW headers and infers proxy span if necessary Updates usage in all contribs that implement function Updates test usage that implement function
Datadog ReportBranch report: ✅ 0 Failed, 5207 Passed, 72 Skipped, 2m 19.94s Total Time |
@zarirhamza @jordan-wong Do you know why the benchmarks are reporting this 50%+ increase in execution time in BenchmarkStartRequestSpan? 🟥 execution_time [+159.899ns; +160.941ns] or [+52.326%; +52.667%] |
spanParentCtx, spanParentErr := tracer.Extract(tracer.HTTPHeadersCarrier(r.Header)) | ||
spanLinksCtx, spanLinksOk := spanParentCtx.(ddtrace.SpanContextWithLinks) |
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.
@zarirhamza @jordan-wong I think this unconditional extraction of spanParentCtx
is the source of the performance impact.
Would it be possible to isolate everything related to the inferred proxy spans so it runs if the feature is activated?
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.
Previously, the span extraction would happen on every call anyway just within the span option func. I tried isolating all behaviors as much as possible so that should improve the performance.
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.
Also unsure if the fact we now have cleanup functions via StartRequestSpans
may result in increased usage that is expected solely due to behavior
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.
Looks like the increased CPU time and memory are to be expected due to the new implementation.
What does this PR do?
This PR introduces functionality to infer proxy spans based on headers that we instruct users to inject upstream, allowing these headers to be propagated downstream. The headers are then used to infer a proxy span to provide increased visibility to a user's trace. The headers are as follows:
x-dd-proxy
aws-apigateway
aws-apigateway
x-dd-proxy-request-time-ms
context.requestTimeEpoch
x-dd-proxy-domain-name
context.domainName
x-dd-proxy-httpmethod
context.httpMethod
x-dd-proxy-path
context.path
x-dd-proxy-stage
context.stage
Motivation
There is no current support for API Gateway and other proxies that do not run Datadog code. By inferring spans via headers, the gaps in observability can be filled to provide a more accurate trace.
Reviewer's Checklist
v2-dev
branch and reviewed by @DataDog/apm-go.Unsure? Have a question? Request a review!