Fix cumulative metrics being incorrectly sent as counters#28
Open
MakonnenMak wants to merge 2 commits intoDataDog:masterfrom
Open
Fix cumulative metrics being incorrectly sent as counters#28MakonnenMak wants to merge 2 commits intoDataDog:masterfrom
MakonnenMak wants to merge 2 commits intoDataDog:masterfrom
Conversation
DogStatsD counters sum all values received during a flush period, which causes cumulative metrics like worker.respawns to be reported incorrectly. For example, if worker.respawns=3 is pushed 5 times per flush period, DogStatsD would report 15 instead of 3. This change sends all uwsgi metrics as DogStatsD gauges instead, which report the last received value. This correctly represents both cumulative metrics (requests, respawns, bytes transmitted) and snapshot metrics (memory usage, worker count). Fixes DataDog#18 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The test now verifies that every metric received is sent with type 'g' (gauge), not just a hardcoded list. This ensures the fix applies universally to all uwsgi metrics. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Author
|
@remeh Was wondering what you think here and if I could get a review |
Contributor
|
Hey @MakonnenMak, thanks for the PR. I don't understand why this change is necessary given that the dogstatsd-all-gauges configuration field already exists. When set to true, it does exactly what you're describing. Am I missing something? I wouldn't be surprised if this field was implemented specifically for your use case. Additionally, I'm concerned that your change might affect behavior for other users. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #18
DogStatsD counters sum all values received during a flush period, which causes cumulative metrics like
worker.respawnsto be reported incorrectly.For example, if
worker.respawns=3is pushed 5 times per flush period, DogStatsD would report 15 instead of 3.Changes
This PR modifies the plugin to send all uwsgi metrics as DogStatsD gauges (|g) instead of counters (|c). Gauges report the last received value, which correctly represents:
Why This Works
DogStatsD Counter Behavior:
metric:5|csent 3 times = reports 15DogStatsD Gauge Behavior:
metric:5|gsent 3 times = reports 5Since uwsgi pushes the same metric value repeatedly until it changes, gauges are the correct type for all uwsgi metrics.
Testing
Updated test suite to verify metrics are sent with the correct type (|g).
🤖 Generated with Claude Code