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 more memcached metrics: get_hit_percent, fill_percent, avg_item_size #283

Merged
merged 2 commits into from
Dec 18, 2012
Merged

Add more memcached metrics: get_hit_percent, fill_percent, avg_item_size #283

merged 2 commits into from
Dec 18, 2012

Conversation

jkoppe
Copy link

@jkoppe jkoppe commented Nov 28, 2012

This is for issue #282.

@alq666
Copy link
Member

alq666 commented Nov 28, 2012

@jkoppe Nice github account :) It may be worth checking that divisors !=0 before doing the division. The try: except: will catch the / 0 but it will log an error.

float(
float(stats["get_hits"]) / float(stats["cmd_get"]) * 100
),
tags=tags
Copy link
Contributor

Choose a reason for hiding this comment

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

Stylistic note: Making this tags=tags, would mean that adding new keyword parameters on the end could be a 1-line diff, rather than needing to edit this line as well to add a comma.

@remh
Copy link

remh commented Nov 28, 2012

@jkoppe Can you use except Exception (and maybe log the exception) instead of except ? as except would also catch keyboard interrupt and system exit
Nice job by the way!

tags=tags
)
except:
self.logger.exception("Cannot calculate memcache.fill_percent for tags: %s" % tags)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't do self.logger.exception('string' % arg), but instead self.logger.exception('string', arg). This will still apply arg as a formatting argument, but will do so only if the log level is high enough that this exception will ever be logged anywhere; otherwise, it avoids needing to do the formatting operation and is thus faster to run.

@jkoppe
Copy link
Author

jkoppe commented Nov 28, 2012

awesome feedback everyone, charles is going to take a stab at cleaning this up :)

- Avoid using `%` for string formatting in log messages when this would
  force formatting for logs which aren't going to be printed.
- Avoid catching throwables not derived from Exception
- Avoid logging on ZeroDivisionError
@clutchski
Copy link
Contributor

I will take a look at this for the next agent release.

@clutchski
Copy link
Contributor

@remh Can you look at this as well?

@remh
Copy link

remh commented Dec 18, 2012

sure

remh pushed a commit that referenced this pull request Dec 18, 2012
Add more memcached metrics: get_hit_percent, fill_percent, avg_item_size
@remh remh merged commit 78dad60 into DataDog:master Dec 18, 2012
@remh
Copy link

remh commented Dec 18, 2012

seems all good

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.

5 participants