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

[exporter/prometheusremotewriteexporter] Do not modify attributes Map in prometheusRW #9736

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- `prometheusreceiver`: Fix the memory issue introduced in the 0.49.0 release (#9718)
- `couchdbreceiver`: Fix issue where the receiver would not respect custom metric settings (#9598)
- `nginxreceiver`: Include nginxreceiver in components (#9572)
- `pkg/translator/prometheusremotewrite`: Fix data race when used with other exporters (#9736)

## v0.50.0

Expand Down
8 changes: 6 additions & 2 deletions pkg/translator/prometheusremotewrite/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,12 @@ func createAttributes(resource pcommon.Resource, attributes pcommon.Map, externa

// Ensure attributes are sorted by key for consistent merging of keys which
// collide when sanitized.
attributes.Sort()
attributes.Range(func(key string, value pcommon.Value) bool {
// Sorting is done on a cloned map, as the original attributes map can read at
// the same time in different places.
cloneAttributes := pcommon.NewMap()
attributes.CopyTo(cloneAttributes)
cloneAttributes.Sort()
cloneAttributes.Range(func(key string, value pcommon.Value) bool {
var finalKey = sanitize(key)
if existingLabel, alreadyExists := l[finalKey]; alreadyExists {
existingLabel.Value = existingLabel.Value + ";" + value.AsString()
Expand Down