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

ThreadStats - Send correct metric type instead of always sending Gauge #242

Merged
merged 9 commits into from
Feb 6, 2018

Conversation

nilabhsagar
Copy link
Contributor

ThreadStats - Send correct Metric Type instead of always sending Gauge

Problem
At present in ThreadStats various types of metric gets created like gauge, count, histogram, etc. but at the time of flushing for each metric type is set to "gauge". This is a problem as sending count from server becomes gauge in the web. Changing the type in web will not have any effect as from the server it is always coming as gauge.

Solution
Assign the right metric type based on the metric functionality.

@nilabhsagar nilabhsagar changed the title ThreadStats - send correct metric type instead of always sending Gauge ThreadStats - Send correct metric type instead of always sending Gauge Nov 16, 2017
@nilabhsagar
Copy link
Contributor Author

The above pull request will fix the issue #245

@jayshao
Copy link

jayshao commented Dec 18, 2017

@nilabhsagar looks like this failed the Travis build for Python 2.5, but only for line-length. Are you still looking at this?

@nilabhsagar
Copy link
Contributor Author

@jayshao Yes, I can fix it. Could you help me with the exact line number to fix.

@nilabhsagar
Copy link
Contributor Author

@jayshao Its fixed now, All Travis build passed.

@nilabhsagar
Copy link
Contributor Author

nilabhsagar commented Jan 2, 2018

Hi, Requesting someone to review and merge with the master?

@nilabhsagar
Copy link
Contributor Author

@yannmh Request you to review.

@nicsnoek
Copy link

Please merge ASAP. Thanks @nilabhsagar for fixing this enormity ;-)

@irabinovitch
Copy link

irabinovitch commented Jan 31, 2018

@nilabhsagar Thanks for reaching out. We have been looking into your PR, and unfortunately it is not mergeable as is. Currently the server side API would also require changes to support some of these metric types. I expect we'll be able to provide more insight into viability and/or timeline next week.

@irabinovitch irabinovitch removed the request for review from masci January 31, 2018 02:19
@nilabhsagar
Copy link
Contributor Author

@irabinovitch Sure, Let me know when some steps are required from my side.

@yannmh
Copy link
Member

yannmh commented Jan 31, 2018

Thanks for working on a fix @nilabhsagar 🙇 I apologize for the late reply.

Your changes look good, and so do the tests.
In order to merge the fix, we'd need to make two additional changes:

  1. Metrics type count (or rate) require an additional interval parameter. It instruments the backend to update the metric metadata accordingly and makes it able to perform time rollup operations (such as as_rate(), as_count...).
    The flush method can be updated to account for this extra parameter, similar to https://github.com/DataDog/dd-agent/blob/master/aggregator.py#L208-L222.
  2. We encourage to use the metric type rate instead of count. Both types are very similar (two representations of the same information), but the rate type is generally more used at Datadog, hence more tested. This can be performed simply by dividing the value by the interval as in https://github.com/DataDog/dd-agent/blob/master/aggregator.py#L210.

Please let me know if you'd like make these changes, or have us add them to your existing PR.

…tric_type

# Conflicts: Resolved
#	datadog/threadstats/base.py
… to update the metric metadata accordingly and makes it able to perform time rollup operations.

2. Changed metric type to rate instead of count.
@nilabhsagar
Copy link
Contributor Author

@yannmh I have done the changes based on your suggestion. I hope it is aligned with your suggestion. Do let me know if I am missing something.

Please verify the commit "7cb37c9" as others are just line wrapping issue fix.

count = sum(self.count, 0)
return [(timestamp, count, self.name, self.tags, self.host)]
return [(timestamp, count, self.name, self.tags, self.host, MetricType.Rate, interval)]
Copy link
Member

Choose a reason for hiding this comment

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

We want to replace count by count/float(interval) to report a proper rate.

self.tags, self.host, MetricType.Gauge, interval),
(timestamp, self.max, '%s.max' % self.name,
self.tags, self.host, MetricType.Gauge, interval),
(timestamp, self.count, '%s.count' % self.name,
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. We need to transform the count to a proper rate.

@yannmh
Copy link
Member

yannmh commented Feb 6, 2018

@nilabhsagar added a small comment.

Other than that, it looks good!

@nilabhsagar
Copy link
Contributor Author

@yannmh Please review.

@yannmh
Copy link
Member

yannmh commented Feb 6, 2018

Thank you @nilabhsagar. This will be part of our next release, which will go out this week.

@yannmh yannmh merged commit b664009 into DataDog:master Feb 6, 2018
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