fix: propagate OTel trace context through the func runtime#167
fix: propagate OTel trace context through the func runtime#167Nachiket-Roy wants to merge 3 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Nachiket-Roy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @Nachiket-Roy! It looks like this is your first PR to knative-extensions/func-go 🎉 |
There was a problem hiding this comment.
Pull request overview
This PR fixes OpenTelemetry trace context propagation for Go functions running behind Knative’s queue-proxy by ensuring W3C traceparent/tracestate headers are extracted on ingress and made available via context.Context to function handlers.
Changes:
- Configure a W3C Trace Context + Baggage
TextMapPropagatorand wrap HTTP/CloudEvents receivers withotelhttp.NewHandler. - Add tests validating that an incoming
traceparentresults in a valid span context in the handler. - Add OpenTelemetry dependencies to
go.mod/go.sum.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
http/service.go |
Adds global propagator configuration and wraps the root handler with otelhttp for context extraction. |
http/service_test.go |
Adds coverage for trace-context propagation into HTTP handler contexts. |
cloudevents/service.go |
Adds global propagator configuration and wraps the CloudEvents receiver with otelhttp. |
cloudevents/service_test.go |
Adds coverage for trace-context propagation into CloudEvents handler contexts. |
go.mod |
Introduces OpenTelemetry module requirements used by the runtime/tests. |
go.sum |
Updates sums for newly introduced OpenTelemetry and transitive dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Changes
This PR resolves issue knative/func#3866 where OpenTelemetry trace propagation would break between Knative's queue proxy and deployed Go functions.
OTel Trace Context Propagation:
TextMapPropagatorusing a composite W3C Trace Context and Baggage propagator in both HTTP and CloudEvents services.otelhttp.NewHandlerto extract incomingtraceparent/tracestateheaders and inject the extracted context into the request context before passing it to the function's handler./kind bug
Fixes knative/func#3866