-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Exporterhelper Exporter] Enable metadata population in exporterhelper when sending_queue is enabled #14139
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
Open
gizas
wants to merge
28
commits into
open-telemetry:main
Choose a base branch
from
gizas:otlphttp_mergge_metadata
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Exporterhelper Exporter] Enable metadata population in exporterhelper when sending_queue is enabled #14139
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5261989
adding first changes for metadata
gizas 5b74827
comment
gizas 5d3f323
adding tests
gizas 32f7498
mod tidy and cahngelog
gizas fbeef6b
mod tidy and cahngelog
gizas 00a18f3
format and adding tests for coverage
gizas e07c0aa
adding metadata keys in xexporterhelper.WithQueueBatch()
gizas 1178536
merging with main
gizas 331a703
update changelog
gizas 5b40717
adding metadata tests
gizas a89aef2
updating test for xexporterhelper
gizas f74f3a4
updating test for xexporterhelper
gizas f4b629f
updating base_exporter and add checks for Partitioner and Mergectx
gizas c290ef6
Merge branch 'main' into otlphttp_mergge_metadata
gizas 77be9c9
updating test for base_exporter
gizas 0836ef7
updating with exporterhelper.WithQueueBatch
gizas c7746e5
Merge branch 'main' into otlphttp_mergge_metadata
gizas 759ac81
removing exporterhelper.WithQueueBatch
gizas d233ec4
Merge branch 'otlphttp_mergge_metadata' of github.com:gizas/opentelem…
gizas bafdd11
updating chloggen message and kept only exporterhelper
gizas e197735
updating chloggen message and kept only exporterhelper
gizas 5c4559b
Merge branch 'main' into otlphttp_mergge_metadata
gizas 8cb459d
removing duplicate xexporterhelper/new_request_test.go test file
gizas 8b766a3
gotidy
gizas 513a1fd
Update exporter/exporterhelper/internal/queuebatch/config_test.go
gizas 5502a54
Merge branch 'main' into otlphttp_mergge_metadata
gizas a341256
combine tests
gizas 2fd73f9
updating description
gizas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Use this changelog template to create an entry for release notes. | ||
|
|
||
| # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
| change_type: enhancement | ||
|
|
||
| # The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
| component: exporter/otlphttp | ||
|
|
||
| # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
| note: Populate metadata into the OTLP HTTP exporter context | ||
|
|
||
| # One or more tracking issues or pull requests related to the change | ||
| issues: [14139] | ||
|
|
||
| # (Optional) One or more lines of additional information to render under the primary note. | ||
| # These lines will be padded with 2 spaces and then inserted directly into the document. | ||
| # Use pipe (|) for multiline entries. | ||
| subtext: | ||
|
|
||
| # Optional: The change log or logs in which this entry should be included. | ||
| # e.g. '[user]' or '[user, api]' | ||
| # Include 'user' if the change is relevant to end users. | ||
| # Include 'api' if there is a change to a library API. | ||
| # Default: '[user]' | ||
| change_logs: [] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package otlphttpexporter // import "go.opentelemetry.io/collector/exporter/otlphttpexporter" | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "fmt" | ||
| "slices" | ||
|
|
||
| "go.opentelemetry.io/collector/client" | ||
| "go.opentelemetry.io/collector/exporter/exporterhelper/xexporterhelper" | ||
| ) | ||
|
|
||
| type metadataKeysPartitioner struct { | ||
| keys []string | ||
| } | ||
|
|
||
| func (p metadataKeysPartitioner) GetKey( | ||
| ctx context.Context, | ||
| _ xexporterhelper.Request, | ||
| ) string { | ||
| var kb bytes.Buffer | ||
| meta := client.FromContext(ctx).Metadata | ||
|
|
||
| var afterFirst bool | ||
| for _, k := range p.keys { | ||
| if values := meta.Get(k); len(values) != 0 { | ||
| if afterFirst { | ||
| kb.WriteByte(0) | ||
| } | ||
| kb.WriteString(k) | ||
| afterFirst = true | ||
| for _, val := range values { | ||
| kb.WriteByte(0) | ||
| kb.WriteString(val) | ||
| } | ||
| } | ||
| } | ||
| return kb.String() | ||
| } | ||
|
|
||
| func (p metadataKeysPartitioner) MergeCtx( | ||
| ctx1, ctx2 context.Context, | ||
| ) context.Context { | ||
| m1 := client.FromContext(ctx1).Metadata | ||
| m2 := client.FromContext(ctx2).Metadata | ||
|
|
||
| m := make(map[string][]string, len(p.keys)) | ||
| for _, key := range p.keys { | ||
| v1 := m1.Get(key) | ||
| v2 := m2.Get(key) | ||
| if len(v1) == 0 && len(v2) == 0 { | ||
| continue | ||
| } | ||
|
|
||
| // Since the mergeCtx is based on partition key, we MUST have the same | ||
| // partition key-values in both the metadata. If they are not same then | ||
| // fail fast and dramatically. | ||
| if !slices.Equal(v1, v2) { | ||
| panic(fmt.Errorf( | ||
| "unexpected client metadata found when merging context for key %s", key, | ||
| )) | ||
| } | ||
| m[key] = v1 | ||
| } | ||
| return client.NewContext( | ||
| context.Background(), | ||
| client.Info{Metadata: client.NewMetadata(m)}, | ||
| ) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.