-
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
Include request headers in client.Info #4547
Conversation
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 looks like a good start, but we are missing:
- A similar change to the configgrpc, adding the metadata to the Header. This might be helpful: https://pkg.go.dev/google.golang.org/grpc/metadata#MD
- Tests
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
Codecov Report
@@ Coverage Diff @@
## main #4547 +/- ##
==========================================
+ Coverage 90.52% 90.54% +0.02%
==========================================
Files 179 179
Lines 10638 10663 +25
==========================================
+ Hits 9630 9655 +25
Misses 785 785
Partials 223 223
Continue to review full report at Codecov.
|
@disq @jpkrohling can we document better the motivation of this? |
@bogdandrutu Since I'm running the collector behind a load balancer, my motivation is actually same one as having the There are other motivations such as running a multi-tenant infra to distinguish between tenants without having to inject something in the actual OTLP data, which is documented in #2401 |
I linked #2401 to this, which should provide enough background on the request. |
4a03aaa
to
0979e5e
Compare
59cb413
to
d6b3294
Compare
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.
Apart from a typo and improved godoc for the new property, this looks good to me.
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
There's a test failure here:
|
@disq, you have enough approvals :-) Could you fix the changelog conflict? Once this is done, this PR will be merged. |
Another conflict? Fixed |
Sorry about that, we do need to find a better solution for the frequent conflicts involving the changelog. |
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.
Sorry I have to blocked this again, but I missed it. We cannot make Info (a.k.a an object in the context) mutable unless is thread-safe because the context is shared between multiple gorutines potentially.
config/configgrpc/configgrpc.go
Outdated
// Include propagates the incoming connection's metadata to downstream consumers. | ||
IncludeMetadata bool `mapstructure:"include_metadata,omitempty"` |
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 want users to be able to select which "metadata" to copy from the request? Maybe not now, but we can be safe and mark this experimental for the moment.
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.
Certainly doable, blindly copying all of it could be bad for memory if the request is decorated with large metadata? But that would also mean we'd have to roll our own md.Copy()
or header.Clone()
routines, as copying-first-then-filtering would be pointless in terms of memory.
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.
That's why I recommend just adding a comment that this is experimental, and we should look a bit into how/if we want this.
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.
@bogdandrutu added
Description: Exposes HTTP headers from the originating request in the
client.Info
struct, to be passed on to processors.This was suggested in the contrib issue open-telemetry/opentelemetry-collector-contrib#6700
I tried to keep it in-line with the
Header
field inhttp.Request
(and grpcmetadata.MD
) as possible (so I just usedmap[string][]string
in an immutable struct with a getter)Closes #2401