Skip to content
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

Add Host property for Metadata #4736

Merged
merged 8 commits into from
Jan 26, 2022
Merged

Conversation

orloffv
Copy link
Contributor

@orloffv orloffv commented Jan 24, 2022

Description: Add Host property for Metadata

Link to tracking Issue: #4722

@orloffv orloffv requested review from a team and tigrannajaryan January 24, 2022 09:10
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 24, 2022

CLA Signed

The committers are authorized under a signed CLA.

client/client.go Outdated Show resolved Hide resolved
client/client.go Outdated Show resolved Hide resolved
config/confighttp/clientinfohandler.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 24, 2022

Codecov Report

Merging #4736 (7825619) into main (2c5eb7c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4736   +/-   ##
=======================================
  Coverage   90.72%   90.73%           
=======================================
  Files         179      179           
  Lines       10689    10696    +7     
=======================================
+ Hits         9698     9705    +7     
  Misses        770      770           
  Partials      221      221           
Impacted Files Coverage Δ
client/client.go 100.00% <ø> (ø)
config/configgrpc/configgrpc.go 92.68% <100.00%> (+0.10%) ⬆️
config/confighttp/clientinfohandler.go 100.00% <100.00%> (ø)
service/config_provider.go 91.96% <100.00%> (ø)
service/flags.go 86.36% <100.00%> (+0.64%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ab3c98...7825619. Read the comment docs.

@orloffv
Copy link
Contributor Author

orloffv commented Jan 24, 2022

@jpkrohling i tried to add in metadata

@orloffv orloffv changed the title Add Host to contextWithClient Add Host property for Metadata Jan 24, 2022
CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
config/confighttp/clientinfohandler.go Outdated Show resolved Hide resolved
Comment on lines 404 to 406
if len(md["Host"]) == 0 && len(md[":authority"]) > 0 {
copiedMD["Host"] = md[":authority"]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove the ":authority" in this case? (Not sure, but want to make sure somebody thinks about this).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no, because it's real header

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, at least as part of this PR here. We might want to start a discussion for something like "semantic conventions" for the headers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpkrohling Is this comment related to host const?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was agreeing in keeping :authority here, as it's the key used by gRPC, and would expect to see it there. The second part of my comment was about having a single value where downstream components would expect the "host" value to exist, but this is being addressed in this PR already. Sorry about the noise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"semantic conventions" for the headers.

This also may include us having the constant values for things like "Host", that's why I got confused. So you are ok with having that constant?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, at least for the moment. If we keep finding ourselves doing it often, we might want to split that out.

@@ -400,7 +400,11 @@ func contextWithClient(ctx context.Context, includeMetadata bool) context.Contex
}
if includeMetadata {
if md, ok := metadata.FromIncomingContext(ctx); ok {
cl.Metadata = client.NewMetadata(md.Copy())
copiedMD := md.Copy()
if len(md[client.MetadataHostName]) == 0 && len(md[":authority"]) > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now what @bogdandrutu meant earlier. I agree with the approach taken here, even though we end up with the host information duplicated in the client.Info. I don't think this is a problem.

@orloffv
Copy link
Contributor Author

orloffv commented Jan 26, 2022

ready to merge or this PR has some problems?

@jpkrohling
Copy link
Member

@bogdandrutu would you please do the honours?

@bogdandrutu bogdandrutu merged commit da91c56 into open-telemetry:main Jan 26, 2022
jpkrohling added a commit to jpkrohling/opentelemetry-collector that referenced this pull request Jan 26, 2022
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
bogdandrutu pushed a commit that referenced this pull request Jan 26, 2022
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
@orloffv orloffv deleted the orloffv.host branch January 27, 2022 12:38
@orloffv orloffv restored the orloffv.host branch January 31, 2022 09:50
orloffv added a commit to orloffv/opentelemetry-collector that referenced this pull request Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants