-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: otel prometheus duplicated attributes #62
Changes from all commits
3fd7b67
d3cd313
1566c21
bf63fb8
499ff92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -159,18 +159,24 @@ func (s *statsdStats) internalNewTaggedStat(name, statType string, tags Tags, sa | |||||||
} | ||||||||
|
||||||||
// Clean up tags based on deployment type. No need to send workspace id tag for free tier customers. | ||||||||
for excludedTag := range s.config.excludedTags { | ||||||||
delete(tags, excludedTag) | ||||||||
} | ||||||||
if tags == nil { | ||||||||
tags = make(Tags) | ||||||||
} | ||||||||
if v, ok := tags[""]; ok { | ||||||||
s.logger.Warnf("removing empty tag key with value %s for measurement %s", v, name) | ||||||||
delete(tags, "") | ||||||||
newTags := make(Tags) | ||||||||
for k, v := range tags { | ||||||||
if strings.Trim(k, " ") == "" { | ||||||||
s.logger.Warnf("removing empty tag key with value %q for measurement %q", v, name) | ||||||||
continue | ||||||||
} | ||||||||
if _, ok := s.config.excludedTags[k]; ok { | ||||||||
continue | ||||||||
} | ||||||||
Comment on lines
+168
to
+170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought I'd leave it for backwards compatibility in case somewhere there is an exclusion rule that would work only before the tag is sanitized. I thought it wouldn't hurt having for now. |
||||||||
sanitizedKey := sanitizeTagKey(k) | ||||||||
if _, ok := s.config.excludedTags[sanitizedKey]; ok { | ||||||||
continue | ||||||||
} | ||||||||
newTags[sanitizedKey] = v | ||||||||
} | ||||||||
// key comprises of the measurement type plus all tag-value pairs | ||||||||
taggedClientKey := tags.String() + fmt.Sprintf("%f", samplingRate) | ||||||||
|
||||||||
// key comprises the measurement type plus all tag-value pairs | ||||||||
taggedClientKey := newTags.String() + fmt.Sprintf("%f", samplingRate) | ||||||||
|
||||||||
s.state.clientsLock.RLock() | ||||||||
taggedClient, found := s.state.clients[taggedClientKey] | ||||||||
|
@@ -179,7 +185,7 @@ func (s *statsdStats) internalNewTaggedStat(name, statType string, tags Tags, sa | |||||||
if !found { | ||||||||
s.state.clientsLock.Lock() | ||||||||
if taggedClient, found = s.state.clients[taggedClientKey]; !found { // double check for race | ||||||||
tagVals := tags.Strings() | ||||||||
tagVals := newTags.Strings() | ||||||||
taggedClient = &statsdClient{samplingRate: samplingRate, tags: tagVals} | ||||||||
if s.state.connEstablished { | ||||||||
taggedClient.statsd = s.state.client.statsd.Clone(s.state.conn, s.statsdConfig.statsdTagsFormat(), s.statsdConfig.statsdDefaultTags(), statsd.Tags(tagVals...), statsd.SampleRate(samplingRate)) | ||||||||
|
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 need this too?
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.
Same as above, better safe than sorry since we might not be the only ones using this lib and I'm not planning to check everywhere if removing it might break an exclusion 🤷♂️