-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: informative user-agent for otlp exporters #3970
feat: informative user-agent for otlp exporters #3970
Conversation
- add collector build info to otlp/otlphttp exporter headers
- move user-agent additions to the exporters - add OS and ARCH to user-agent
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 a good feature to add. Just one question regarding the following in the description:
Currently, it's possible to add a user-agent header to the HTTP exporter via the headers config. This change preserves this behavior, and only sets the collector user-agent, if one is not present in config headers.
Currently, it's not possible to do the above with a gRPC exporter. This change does not affect that, and only updates the existing gRPC client user-agent.
My understanding is that this is currently possible for the grpc exporter via the headers
configuration and and not for the http exporter, but the comment in the description makes me think it's the other way around. Can you confirm this?
Confirmed in local testing:
|
Thanks for clarifying 👍 |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
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.
PR looks good, please resolve the conflict.
Merged upstream, and a couple small updates adding a doc comment and parenthesis around (OS/ARCH) |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Didn't get a chance to review the feedback last week, but will do that this week 🙏 |
Codecov Report
@@ Coverage Diff @@
## main #3970 +/- ##
=======================================
Coverage 90.77% 90.78%
=======================================
Files 179 179
Lines 10412 10423 +11
=======================================
+ Hits 9452 9463 +11
Misses 743 743
Partials 217 217
Continue to review full report at Codecov.
|
@bogdandrutu yes, I plan on updating this today -- are you OK with a custom roundtripper that clones the request and updates the header? |
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.
few more comments about limiting the public API, and avoid implementing roundtripper if we don't intend that to be used by others.
exporter/exporterhelper/common.go
Outdated
@@ -232,3 +234,8 @@ func (ts *timeoutSender) send(req request) error { | |||
} | |||
return req.export(ctx) | |||
} | |||
|
|||
// DefaultUserAgent User-Agent value used by exporters | |||
func DefaultUserAgent(info component.BuildInfo) string { |
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.
let's move this to otlpexporter for the moment or an internal package. Prefer to limit the public API.
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.
✅ Moved to each exporter f5bddaf
exporter/otlphttpexporter/otlp.go
Outdated
@@ -213,3 +218,32 @@ func readResponse(resp *http.Response) *status.Status { | |||
|
|||
return respStatus | |||
} | |||
|
|||
type userAgentRoundTripper struct { |
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.
Do we really need a roundtripper? Since this is private, we should just simply add a header to the request when creating the request instead of cloning etc., as we need to do for a proper roundtripper.
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 did consider just adding the header when request is created, which is easier but more error-prone (need to remember to add the header again, if there's ever a new codepath that creates requests). That being said, I expect the exporter is fairly stable at this point, so this should be OK? f5bddaf
@bogdandrutu let me know if there's anything I need to do about the codecov report -- as far as I can tell, coverage is actually up, so I'm not sure what the failure is telling me |
It's not a problem with this PR. It's just telling that the project as a whole is under the target of 90%, which has been the case since we brought the builder here. |
Closing and re-opening to kick the CI |
@open-telemetry/collector-maintainers please merge once CI passes, looks like we have all the approvals needed |
The new release created a conflict for this PR. Sorry about that, but could you rebase the changelog, @vreynolds? |
@jpkrohling conflict resolved ✅ |
@tigrannajaryan @bogdandrutu please merge 😬 |
Description: This adds a default user-agent header to outgoing requests by the OTLP/gRPC and OTLP/HTTP exporters. The default user-agent contains build information about the collector.
Behavior details:
headers
config. This change preserves this behavior, and only sets the collector user-agent, if one is not present in config headers.Link to tracking Issue: Fixes #2209
Testing: Updated/added to existing unit tests. Built a local collector and verified outgoing user-agent headers in both exporters.
Documentation: N/A?