[TEEP-4505] [datadog_checks_base] Add use_per_instance_collection option for PDH counters#22298
Open
ArmentaRoberto wants to merge 2 commits intomasterfrom
Open
[TEEP-4505] [datadog_checks_base] Add use_per_instance_collection option for PDH counters#22298ArmentaRoberto wants to merge 2 commits intomasterfrom
ArmentaRoberto wants to merge 2 commits intomasterfrom
Conversation
Some Windows PDH counters return incorrect values (zeros) when using the bulk PdhGetFormattedCounterArrayW API, but work correctly with per-instance GetFormattedCounterValue calls. This adds a new object-level configuration option that enumerates instances via EnumObjectItems and creates individual counter handles, then collects each using the per-instance API. Known affected counters: - SQLServer:Workload Group Stats\CPU usage % - MSSQL$<instance>:Workload Group Stats\CPU usage %
Codecov Report❌ Patch coverage is Additional details and impacted files🚀 New features to boost your workflow:
|
Author
|
CI failures in snmp and mongo are pre-existing flaky tests unrelated to this PR. The datadog_checks_base tests pass. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3bfabb471f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
datadog_checks_base/datadog_checks/base/checks/windows/perf_counters/counter.py
Show resolved
Hide resolved
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.
Some Windows PDH counters return incorrect values (zeros) when using the bulk PdhGetFormattedCounterArrayW API, but work correctly with per-instance GetFormattedCounterValue calls.
This adds a new object-level configuration option that enumerates instances via EnumObjectItems and creates individual counter handles, then collects each using the per-instance API.
Known affected counters:
What does this PR do?
Adds a new
use_per_instance_collectionconfiguration option for Windows PDH performance counter objects. When enabled, instead of using wildcard paths with bulkPdhGetFormattedCounterArrayWretrieval, instances are enumerated viaEnumObjectItemsand collected individually usingGetFormattedCounterValue.This provides a workaround for counters where the bulk API returns incorrect values (typically zeros) while per-instance retrieval works correctly.
Motivation
Certain Windows PDH counters, notably
SQLServer:Workload Group Stats\CPU usage %, return zero values when collected via the bulkPdhGetFormattedCounterArrayWAPI. This is a known limitation of some PDH counter providers. The per-instanceGetFormattedCounterValueAPI returns correct values for the same counters.https://datadoghq.atlassian.net/browse/AGENT-15204
Customer impact: SQL Server Resource Governor CPU metrics were reporting 0% despite actual workload activity, making capacity planning and performance monitoring impossible.
How to test the change?
typeperfoutputPossible Drawbacks / Trade-offs
Additional Notes
falsefor backward compatibilityMultiCounterobjects; single-instance counters log a warning if option is setReview checklist (to be filled by reviewers)
qa/skip-qalabel if the PR doesn't need to be tested during QA.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged