[datadog_checks_base] Add include_total option for Windows perf-counter framework#23530
Draft
[datadog_checks_base] Add include_total option for Windows perf-counter framework#23530
Conversation
…er framework Add a per-performance-object include_total option (default false) to the Windows perf-counter framework. When set to true, the _Total aggregate instance is no longer excluded by default and can be collected. The previous behaviour (always exclude _Total) is preserved, so this is strictly opt-in and backwards-compatible.
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: be53280 | Docs | Datadog PR Page | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
Contributor
Validation Report
Run Passed validations (18)
|
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.
What does this PR do?
Adds a per-performance-object
include_total: booloption (defaultfalse) to the Windows perf-counter framework indatadog_checks_base.When set to
true, the framework no longer hardcodes\b_Total\binto the exclude pattern, so the_Totalaggregate instance is collected like any other instance. Default behaviour is unchanged.Motivation
Reported via AGENT-16101. A customer is migrating an integration from the legacy PDH-based framework (where they could collect
_Total) to the current PdhCounterSet framework (where_Totalis unconditionally excluded). They rely on_Totalaggregates for capacity dashboards and have no in-Agent way to opt back into them.The current behaviour was introduced as a sensible default to prevent double-counting, and that default should stay. But there are legitimate cases where the aggregate is the metric the user wants, so an opt-in escape hatch is reasonable.
This is conceptually adjacent to #22028 which let users opt out of the default exclude behaviour for namespaced instances —
include_totalextends the same idea to the_Totalrow specifically.Describe how you validated your changes
py_compileclean oncounter.pyandtest_filter.py._instance_excludedlogic — all pass. Cases include:_Totalstill excluded, behaviour unchanged)include_total: true(_Totalkept, other defaults still applied)include: [_total]config (still dropped without opt-in, kept with opt-in)(?!)never-match sentinel edge case (soexclude_pattern.search()callers don't have to handleNone)test_include_total,test_include_total_with_lowercase_instance,test_include_total_respects_user_exclude. These are gatedrequires_windows, so they skip locally on darwin and run on the Windows CI runner.Possible Drawbacks / Trade-offs
_Totalalongside summed per-instance metrics.Additional Notes
Draft - opening for review while a customer-built wheel is shared with the reporter for validation against their environment.