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

Use proper metric type for counter values #4

Merged

Conversation

invernizzie
Copy link

Counter and rate type metrics shouldn't be backed by a DogStatsD gauge because only the last value in the flush interval is submitted for gauges.

While that will work for a single go-metrics registry reporting to DogStatsD, whenever more multiple registries increment the same counter (e.g. from multiple processes or containers on the same host), intermediate values will be lost.

Say, for example, that two instances a and b increment the same counter multiple times during a DogStatsD flush interval (reporting is ordered chronologically from left to right):

a:   0     2 3
b: 0   1 2

With a counter type, one would expect the value submitted to datadog for the flush interval to be 5—increments are submitted and added by the DogStatsD during the flash interval. However, a gauge only keeps and submits the last value, in this case 3 which is incorrect.

This MR fixes this by using the count type for histogram, meter, and timer counters.

@invernizzie invernizzie changed the title Use rate metric type for counter values Use proper metric type for counter values Nov 9, 2021
@syntaqx syntaqx merged commit 2095153 into syntaqx:main Mar 8, 2022
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.

2 participants