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

Add optional tags to metrics #105

Closed
wants to merge 1 commit into from
Closed

Conversation

GrivIN
Copy link

@GrivIN GrivIN commented Mar 9, 2018

This PR adds possibility to add tags to StatsD protocol for Prometheus metrics exporter and similar.

# standard call
StatsClient().timing(stat, delta, rate=1)
# extended call
StatsClient().timing(stat, delta, rate=1, tags={'worker': 'one', 'env': 'prod'})

Protocol/Extension details https://github.com/prometheus/statsd_exporter#dogstatsd-extensions

@jsocol
Copy link
Owner

jsocol commented Mar 9, 2018

Thanks for the very thorough patch, with docs and tests!

I'm not planning to add tag support to the project, and the most recent discussion around it is documented in #83.

Alternatives exist. I can't vouch for any of these, but there are...

  1. a promethus client
  2. a fork called statsd-tags (though I can't find the github repo anymore)
  3. a datadog client
  4. another fork statsd-telegraf with tags support

All my concerns in this comment #83 (comment) still apply, and especially those in this comment #83 (comment), that adding tag support fundamentally changes how you name metrics, so it's not something that can transparently fail.

Maybe there's a way, and I would definitely be open to this, for a series of refactors to make it easier to write userland code—or perhaps another package that wrapped this one—to add support for tags. I suspect it would be fairly straight forward, if a couple of internal methods—but not the public methods—took an extra/args/kwargs and passed it alone, if we pulled the string formatting out into an overrideable place, and if instead of StatsClient().timer() used a cls.timer_cls instead of a direct reference to Timer... stuff along those lines. Basically changing the internal representation of a metric to something a little more flexible without changing the public API.

Most of the public methods are very thin, so a subclass that overrode them to add tags (maybe ['datadog', 'style'] or {'telegraph': 'style'}) wouldn't have to do much work downstream.

@GrivIN GrivIN closed this Mar 12, 2018
@Tzvika-m
Copy link

@jsocol just so you know, all the alternatives you suggested are either deprecated, removed or irrelevant.

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.

None yet

3 participants