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

[memcached] Additional stats metrics #2491

Merged
merged 1 commit into from
May 18, 2016
Merged

[memcached] Additional stats metrics #2491

merged 1 commit into from
May 18, 2016

Conversation

truthbk
Copy link
Member

@truthbk truthbk commented May 11, 2016

Why

This PR adds support for memcached "items" statistics as reported by stats items. It also attempts to simplify the inclusion of additional optional metrics. To do so, it introduces a map of stats arguments (ie. items) to a list of rate metrics, gauge metrics, and if needed a raw stat output handler.

In the particular case of the items statistics, we need an output handler because we need to parse the raw key value (with form "items:<slab_id>:<metric_name>" to extract the <slab_id> and actual metric name. The actual value remains untouched - no need to operate over it. We can then use the slab_id to tag the relevant metrics. All handlers are expected to return a tuple of metric_name, tags, and actual value.

Enabling optional metrics requires configuring the optional_metrics flag in the memcached yaml.

Open Questions

  • should each of the optional metrics get its own feature flag?
  • currently namespacing optional metrics as follows: memcached.<stats_arg>.<metric_name> - yes? no?

Reference

https://github.com/memcached/memcached/blob/master/doc/protocol.txt

@degemer
Copy link
Member

degemer commented May 11, 2016

Memcached CI is failing on a coverage issue, it's probably legitimate. https://travis-ci.org/DataDog/dd-agent/jobs/129498510

@degemer
Copy link
Member

degemer commented May 11, 2016

A few confirmations/nitpicks:

  • The exceptions are not re-raised for the optional metrics, so no service check is sent. Is it because the optional metrics are really optional and could fail while the others would still be there ?
  • Maybe you could add a bit more documentation in the check conf files, specifying what are the collected optional metrics.

Looks good otherwise.

For the feature flag question, I'd say that if it was possible to regroup the optional metrics by type, it would be then possible to hide each type behind one feature flag. But I don't know really know memcached, so it may not be the best idea.
Idem for the second question, you have to know memcached to be able to answer.

@truthbk
Copy link
Member Author

truthbk commented May 13, 2016

@degemer the reason I don't re-raise the exception for the optional metrics is precisely to avoid having the optional metrics trigger a failed service check if the default metrics succeed. It felt redundant. In principle, items stats wouldn't fail if the default metrics don't but I could foresee a few scenarios (like memcached not reporting all possible subsets of optional metrics due to some configuration directive, etc).

I think the right thing is probably to namespace the metrics, so I will make changes in that direction. We can then revisit and if we don't agree it's better, I'll revert.

@truthbk
Copy link
Member Author

truthbk commented May 13, 2016

@degemer I'm actually having a bit of a hard-time deciding if I want to make some of those gauges into rates as well.... So I'll take a look at that as well.

@remh remh added this to the 5.8.0 milestone May 17, 2016

def _get_optional_metrics(self, client, tags, options=None):
for arg, metrics_args in self.OPTIONAL_STATS.iteritems():
if not options or options.get(arg, False):
Copy link
Member

@degemer degemer May 17, 2016

Choose a reason for hiding this comment

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

Shouldn't this be if options and options.get(arg, False) ? (default: no optional metrics ?)

Copy link
Member Author

Choose a reason for hiding this comment

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

@degemer Not really, I supposed that if you called the method without setting the options dict, then you wanted all options (otherwise you wouldn't call the _get_optional_metrics() method). On the other hand if you do set the options dict, then only collect what is set to True there.

I enforce the logic you're thinking about in check() where we only call _get_optional_metrics() if options are set in the YAML.

Let me know if you disagree.

Copy link
Member

Choose a reason for hiding this comment

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

It makes sense, and the default of options is {} anyway, so 👍

@degemer
Copy link
Member

degemer commented May 17, 2016

LGTM apart from the small remarks.

One question though: why didn't you enable coverage_report for the optional metrics tests ?

@truthbk
Copy link
Member Author

truthbk commented May 18, 2016

@degemer because I forgot... lol

@degemer
Copy link
Member

degemer commented May 18, 2016

Feel free to merge once the CI is 💚

[memcached] define optional_metrics paramenter in config file.

[memcached] fixing up metric namespace - prepend with argument.

[memcached] adding slabs optional metrics.

[memcached] updating metric types, adding tests.

[memcached] get coverage report for tests.
@truthbk truthbk force-pushed the jaime/memcached_stats branch from a802bdf to 0674b1c Compare May 18, 2016 16:51
@truthbk truthbk merged commit 7431e60 into master May 18, 2016
@truthbk truthbk deleted the jaime/memcached_stats branch May 18, 2016 21:28
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.

3 participants