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

Allow support for inconsistent label sets by marking metrics registered as unchecked collectors #194

Merged
merged 2 commits into from
Apr 9, 2019
Merged

Allow support for inconsistent label sets by marking metrics registered as unchecked collectors #194

merged 2 commits into from
Apr 9, 2019

Conversation

vsakhart
Copy link

In the current version of the statsd exporter, if a metric with a label set is sent to the statsd exporter with a label set inconsistent with an existing registered metric then that metric gets dropped. e.g foo{a="1"} is sent first and then foo{b="1"} is sent but then dropped.

This functionality was officially supported in the Go Prometheus Client via the addition of unchecked collectors. This PR makes it so each metric added is an unchecked collector which will allow metrics with inconsistent label sets not to be dropped.

I couldn't find a more elegant way to add the metric to the container map without string concat so let me know if there could be a better solution.

The test is also covering a lot of cases within one test case given that the change touches all metrics registration code so let me know if you want me to refactor that at all.

This fixes #114.

@matthiasr

Copy link
Contributor

@matthiasr matthiasr left a comment

Choose a reason for hiding this comment

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

This looks very good, thank you very much! Only one small request.

exporter.go Outdated
@@ -87,23 +96,28 @@ func NewCounterContainer() *CounterContainer {
}

func (c *CounterContainer) Get(metricName string, labels prometheus.Labels, help string) (prometheus.Counter, error) {
counterVec, ok := c.Elements[metricName]
labelNames := getLabelNames(labels)
mapKey := metricName + "," + strings.Join(labelNames, ",")
Copy link
Contributor

Choose a reason for hiding this comment

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

you're doing this in several places, please break it out into a function so that we can be sure it's consistent

@matthiasr
Copy link
Contributor

Oh also, please add the DCO sign-off to your commits. It's unfortunately required.

Vitaliy Sakhartchouk added 2 commits March 29, 2019 13:18
registered as unchecked collectors

Signed-off-by: Vitaliy Sakhartchouk <[email protected]>
Signed-off-by: Vitaliy Sakhartchouk <[email protected]>
@vsakhart
Copy link
Author

vsakhart commented Apr 5, 2019

ping @matthiasr :)

@matthiasr
Copy link
Contributor

Sorry, I was on vacation for the last week and am still catching up. I'll review this week.

@matthiasr
Copy link
Contributor

Thank you!

@matthiasr matthiasr merged commit 43cef6c into prometheus:master Apr 9, 2019
matthiasr pushed a commit that referenced this pull request Apr 9, 2019
Signed-off-by: Matthias Rampke <[email protected]>
matthiasr pushed a commit that referenced this pull request May 15, 2019
* [CHANGE] Do not run as root in the Docker container by default ([#202](#202))
* [FEATURE] Add metric for count of events by action ([#193](#193))
* [FEATURE] Add metric for count of distinct metric names ([#200](#200))
* [FEATURE] Add UNIX socket listener support ([#199](#199))
* [FEATURE] Accept Datadog [distributions](https://docs.datadoghq.com/graphing/metrics/distributions/) ([#211](#211))
* [ENHANCEMENT] Add a health check to the Docker container ([#182](#182))
* [ENHANCEMENT] Allow inconsistent label sets ([#194](#194))
* [ENHANCEMENT] Speed up sanitization of metric names ([#197](#197))
* [ENHANCEMENT] Enable pprof endpoints ([#205](#205))
* [ENHANCEMENT] DogStatsD tag parsing is faster ([#210](#210))
* [ENHANCEMENT] Cache mapped metrics ([#198](#198))
* [BUGFIX] Fix panic if a mapping resulted in an empty name ([#192](#192))
* [BUGFIX] Ensure that there are always default quantiles if using summaries ([#212](#212))
* [BUGFIX] Prevent ingesting conflicting metric types that would make scraping fail ([#213](#213))

With #192, the count of events rejected because of negative counter increments has moved into the `statsd_exporter_events_error_total` metric, instead of being lumped in with the different kinds of successful events.

Signed-off-by: Matthias Rampke <[email protected]>
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.

Fix use of client_golang to allow inconsistent labels on metrics
2 participants