-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
otlpmetricgrpc: Keep metadata for gRPC in context (#5892)
When using otlpmetricgrpc, we can inject metadata dynamically with `metadata.AppendToOutgoingContext`. However when specifying headers with `WithHeaders`, it becomes impossible to add additional metadata. For example, the code below sends additional metadata in the header ```go exp := otlpmetricgrpc.New(context.Background()) ctx := context.Background() ctx = metadata.AppendToOutgoingContext(ctx, "dynamic-key", "value") exp.Export(ctx, &metricdata.ResourceMetrics{})) ``` But when using `WithHeader` like below, no additional metadata will be sent ```go exp := otlpmetricgrpc.New(context.Background(), otlpmetricgrpc.WithHeaders("custom-key", "value")) ctx := context.Background() ctx = metadata.AppendToOutgoingContext(ctx, "dynamic-key", "value") exp.Export(ctx, &metricdata.ResourceMetrics{})) ``` To eliminate this inconsistency, keep the metadata in the context and send them in the header. --------- Co-authored-by: Tyler Yahn <[email protected]>
- Loading branch information
Showing
3 changed files
with
15 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters