-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: include OTel semconv 1.20 attributes in spans #306
Conversation
The 1.21+ HTTP attributes are not yet stable. Update handler to use the attributes other current instrumentation is using so that existing queries match.
I reckon we can decide on whether/how to implement the I'll add some tests to expect these attributes to appear and then wrap up this PR as-is. |
This change got more invasive than I initially intended. I extracted most of the attribute setting to a function that returns a slice of attributes. This avoids needing to create a span and retrieve it from some test exporter to assert the which attributes are produced by which logic branches. The test is not yet comprehensive of those branches, though.
Wrapped chunks of the test in t.Run() to give them more visible names when the test suite runs.
Might have gotten carried away with refactoring the code to make unit testing simpler. 😬 |
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 like what your refactoring is doing. Maybe it could go one step further so the handleEvent
func is responsible for creating the span, then we have handleHTTPEvent
funcs that gather the specific event type attrs and the span name. This will make adding more event type handlers easier / cleaner.
Something like:
func handleHTTPEvent(event) (spanName string, attrs []attribute.keyvalye)
😈 You read my mind, @MikeGoldsmith, but I held off because I thought I was already going pretty far in this refactor. I considered again having a |
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.
This is great! I suggested a few more attributes to a test case but then I think this is good to go!
Also noting this table for quick reference, in preparation for docs updates: "http.request.method" / "http.method" |
Co-authored-by: Jamie Danielson <[email protected]>
Which problem is this PR solving?
The 1.21+ HTTP attributes are not yet stable. Per the HTTP semantic convention v1.21/v1.22 guidance, we should send the "old" style attributes. Doing so will help the agent's telemetry play better with others when appearing alongside application instrumentation in the same set of services.
Short description of the changes
Proposed future followup:
OTEL_SEMCONV_STABILITY_OPT_IN
flag for opting in to the new, as-yet unstable attribute names?