-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[webhookeventreceiver] add option to include headers as attributes #37815
Conversation
3911d55
to
887ca37
Compare
Hey this is really great! A couple of small things: First in |
Thanks for the quick review and feedback! I think I've addressed it in my latest commit but let me know. re: |
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.
lgtm! Thanks!
func headerAttributeKey(header string) string { | ||
snakeCaseHeader := strings.ReplaceAll(header, "-", "_") | ||
snakeCaseHeader = strings.ToLower(snakeCaseHeader) | ||
return "header." + snakeCaseHeader |
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.
Any reason to transform to snake case? That can be done later in a processor
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.
Was (maybe poorly) trying to conform to https://opentelemetry.io/docs/specs/semconv/general/naming/
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.
The issue is that this is input data, not a deterministic piece of data. You can have collision right now such as two headers with the names “content-length” and “Content Length”. It’s better to let processors perform data sanitization.
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.
Fair enough. For our use case it would indeed be easy enough to do this in a processor as you say, without baking it in here. What do you think about maintaining the header.
namespace? I think it would still be useful to differentiate the attributes this way.
Updated PR to address feedback on multi-values and switch to using regex instead. I also added a comment to Switching to regex was a little more complex, since I wanted to ensure the regex was validated on startup and also pass the compiled regex down to reqToLog. I made a couple of changes:
|
5e98f29
to
ee0e3e1
Compare
I opened another PR against the same receiver. When this merges, I'll rebase. #38042 |
👋 Pushed a rebase after the last PR was merged. Is there any feedback here that still needs to be addressed? |
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.
Generated code is out of date, please run "make generate" and commit the changes in this PR.
also please fix lint http://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/13655296572/job/38267389141?pr=37815
- set ConvertHeadersToAttributes to false in `createDefaultConfig` - Adds additional test cases for ReqToLog - Adds tests for normalized header attribute key
ran |
Description
Hi! I'm looking to add a feature to the webhookeventreceiver to allow HTTP request headers to be passed through as log attributes. Our initial use case for this is for receiving webhook events from Github/Github Enterprise - which stores important metadata in the webhook request headers that is absent from the payload.
This PR adds a new option,
convert_headers_to_attributes
, which will include any headers except the one specified inrequired_header
in the payload as an attribute.Link to tracking issue
Fixes
N/A - started with this PR
Testing
Added unit tests and I'm running this successfully in our environment using a local build.
Documentation
README