-
Notifications
You must be signed in to change notification settings - Fork 443
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
Add inferred proxy spans #3052
base: main
Are you sure you want to change the base?
Add 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-07 16:10:31 Comparing candidate commit b356a70 in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 58 metrics, 0 unstable metrics. scenario:BenchmarkStartRequestSpan-24
|
assert.Equal(2, len(spans)) | ||
gateway_span := spans[0] | ||
web_req_span := spans[1] | ||
assert.Equal("aws.apigateway", gateway_span.OperationName()) |
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.
Can you add tests to make sure the other aspects of the span metadata is present? Some examples can be found in the JS version: https://github.com/DataDog/dd-trace-js/pull/4837/files#diff-30cfe20da922154edf4288007e440ef1fc0873c26813eb2cc7c78e064024ebd0 .
Namely, span metadata like:
- component
- http.* (like http.url, http.status_codes)
I'm curious if you can assert that the inferred span in Go follows the underlying span created by httptrace.
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.
Currently working through a bug I found related to this in expected tag assertion
I'm curious if you can assert that the inferred span in Go follows the underlying span created by httptrace.
I am assuming you mean asserting that httptrace is a parent of the inferredSpan? - I have a line that checks this https://github.com/DataDog/dd-trace-go/pull/3052/files#diff-5c136a85a92fba2b6b3bdb1a3b8f5c43ed87d3dcb3d65a4bab64d68df68b769cR88
assert.True(web_req_span.ParentID() == gateway_span.SpanID())
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.
Sorry, to clarify, I mean asserting that the httptrace span and the inferred span have matching:
- status codes
- http urls
- type
PROXY_HEADER_SYSTEM = "X-Dd-Proxy" | ||
//PROXY_HEADER_START_TIME_MS = "x-dd-proxy-request-time-ms" | ||
PROXY_HEADER_START_TIME_MS = "X-Dd-Proxy-Request-Time-Ms" | ||
PROXY_HEADER_PATH = "X-Dd-Proxy-Path" | ||
PROXY_HEADER_HTTPMETHOD = "X-Dd-Proxy-Httpmethod" | ||
PROXY_HEADER_DOMAIN = "X-Dd-Proxy-Domain-Name" | ||
PROXY_HEADER_STAGE = "X-Dd-Proxy-Stage" |
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.
Just a question: Is this casing Go syntax specific? I noticed in the test that it'd work with x-dd-proxy-path
.
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.
Golang's http library parses and returns http request header content in "Canonical Form" with each word capitalized, so when accessing headers from a request we need to reference the exact spelling. https://ron-liu.medium.com/what-canonical-http-header-mean-in-golang-2e97f854316d
In the tests we are passing in the headers to create a new Request, so the http library automatically formats/capitalizes our headers to canonical form for us even if we pass in lowercased strings.
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 |
return nil | ||
} | ||
|
||
// Q: is it possible to have multiple values for any of these http headers?? |
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.
Is this comment asking if it's possible for something like domain to have multiple "domain values"? At the moment, I don't think so.
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.
HTTP headers may have multiple values but it's up to specs to treat each header as a concrete value or a list of them, according to RFC 7231:
Authors of specifications defining new header fields are advised to consider documenting:
- Whether the field is a single value or whether it can be a list (delimited by commas; see Section 3.2 of [RFC7230]). If it does not use the list syntax, document how to treat messages where the field occurs multiple times (a sensible default would be to ignore the field, but this might not always be the right choice).
So, whoever is emitting PROXY_HEADER_DOMAIN need to confirm if it may have multiple values or not. The same for the rest of headers.
What does this PR do?
Motivation
Reviewer's Checklist
v2-dev
branch and reviewed by @DataDog/apm-go.Unsure? Have a question? Request a review!