[pkg/ottl] Add client metadata access to OTTL contexts#41879
[pkg/ottl] Add client metadata access to OTTL contexts#41879evan-bradley merged 65 commits intoopen-telemetry:mainfrom
Conversation
Add `metadata` and `metadata["key"]` path expressions to access client request metadata in all OTTL transformation contexts. Fixes open-telemetry#33288
# Conflicts: # pkg/ottl/go.mod # pkg/ottl/go.sum
Thanks @ronkorland, I've addressed the final suggestions I had, one adapting the transform context to use pointer (recent standard changes), added some security and best practices section on the docs, and finally a feature gate to temporarily allow users to disable the new context access, see 3685ffa and 50be0be. @TylerHelmuth @evan-bradley, it looks good to me, please have a final look so we can finally move this feature forward. Thank you! |
…y-collector-contrib into metadata-context # Conflicts: # connector/countconnector/go.mod # connector/signaltometricsconnector/go.mod # connector/signaltometricsconnector/go.sum # connector/sumconnector/go.mod # connector/sumconnector/go.sum # internal/filter/go.mod # internal/filter/go.sum # pkg/ottl/go.mod # pkg/ottl/go.sum # processor/filterprocessor/go.mod # processor/filterprocessor/go.sum # processor/logdedupprocessor/go.mod # processor/logdedupprocessor/go.sum # processor/lookupprocessor/go.mod # processor/lookupprocessor/go.sum # processor/spanprocessor/go.mod # processor/spanprocessor/go.sum # processor/tailsamplingprocessor/go.mod # processor/tailsamplingprocessor/go.sum # processor/transformprocessor/go.mod # processor/transformprocessor/go.sum
|
@edmocosta thanks for the ping. I have reviewed the latest changes in 3685ffa and 50be0be. The security documentation and the feature gate are excellent additions. I'm aligned with these updates and ready for the code owners' final review |
|
/easycla |
…y-collector-contrib into metadata-context # Conflicts: # connector/countconnector/go.mod # connector/signaltometricsconnector/go.mod # connector/signaltometricsconnector/go.sum # connector/sumconnector/go.mod # connector/sumconnector/go.sum # internal/filter/go.mod # internal/filter/go.sum # pkg/ottl/go.mod # pkg/ottl/go.sum # processor/filterprocessor/go.mod # processor/filterprocessor/go.sum # processor/logdedupprocessor/go.mod # processor/logdedupprocessor/go.sum # processor/lookupprocessor/go.mod # processor/lookupprocessor/go.sum # processor/spanprocessor/go.mod # processor/spanprocessor/go.sum # processor/tailsamplingprocessor/go.mod # processor/tailsamplingprocessor/go.sum # processor/transformprocessor/go.mod # processor/transformprocessor/go.sum
evan-bradley
left a comment
There was a problem hiding this comment.
Thanks @ronkorland. Looks good to me.
…etadata - Added a reference URL for issue tracking related to the `otelcol` context. - Specified the version from which the feature gate is available.
…simplifying code - Removed several unused functions related to gRPC and client metadata accessors. - Consolidated logic for converting string arrays to value slices. - Improved code readability and maintainability by eliminating redundant error handling and comments.
Resolved go.mod/go.sum conflicts by taking main's versions; re-added collector/client in pkg/ottl for otelcol context.
|
@evan-bradley I've addressed your feedback: |
|
Thanks @ronkorland. Looks good to me, just needs a |
done |
|
Thank you for your contribution @ronkorland! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help. |
|
Saw again that this was opened in August of last year, just want to thank you again for being patient throughout the review process. |
|
Thank you @ronkorland for your great work and patience. I'm glad this feature finally landed :) |
|
Thank you @edmocosta and @evan-bradley for the thorough reviews and for sticking with this PR since August! I really appreciate the guidance on the feature gate implementation and the final refactoring. I'm excited to see this land, and I'll be keeping an eye on the tracking issue for the feature gate moving forward. I'd be happy to jump back in for any further code changes or improvements needed, so please don't hesitate to reach out |
Description
This PR adds metadata access capability to all OTTL (OpenTelemetry Transformation Language) contexts, enabling users to access client request metadata within OTTL transformations.
What this achieves:
metadatapath expression to access the entire client metadata objectmetadata["key"]path expression to access specific metadata values by keyImplementation details:
ctxmetadatapackage with path expression parserclient.Metadatatype for full metadata accessstringornilfor specific key access (first value if multiple exist)Link to tracking issue
Fixes #33288
Testing
pkg/ottl/contexts/internal/ctxmetadata/metadata_test.goDocumentation
pkg/ottl/contexts/ottldatapoint/README.mdpkg/ottl/contexts/ottllog/README.mdpkg/ottl/contexts/ottlmetric/README.mdpkg/ottl/contexts/ottlprofile/README.mdpkg/ottl/contexts/ottlprofilesample/README.mdpkg/ottl/contexts/ottlresource/README.mdpkg/ottl/contexts/ottlscope/README.mdpkg/ottl/contexts/ottlspan/README.mdpkg/ottl/contexts/ottlspanevent/README.mdmetadatapath description and return type (client.Metadata)metadata[""]path description and return type (stringornil)