-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[receiver/windowsperfcounters] fix: Drop metrics with empty datapoint…
…s. (#32384) **Description:** When scraping Windows Performance Counters, it's possible that some counter objects do not exist. When that is the case, `windowsperfcounters` will still create the `Metric` object with no datapoints in it. Some exporters throw errors when encountering this. The fix proposed in this PR does an extra pass after all metrics have been scraped and removes the `Metric` objects for which no datapoints were scraped. **Link to tracking Issue:** #4972 **Testing:** - Confirmed that `debug` exporter sees `ResourceMetrics` with no metrics and doesn't throw. - Confirmed that `prometheusremotewrite` exporter no longer complains about empty datapoints and that it skips the export when no metrics are available - ~No unit tests added for now. I will add a unit test once I have confirmation that this is the right way to remove empty datapoints~ Unit test covering the changes and enabling fixture validation which was not implemented.
- Loading branch information
Showing
7 changed files
with
81 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
change_type: bug_fix | ||
component: windowsperfcountersreceiver | ||
note: Metric definitions with no matching performance counter are no longer included as metrics with zero datapoints in the scrape output. | ||
issues: [4972] | ||
subtext: | ||
change_logs: [user] |
14 changes: 14 additions & 0 deletions
14
receiver/windowsperfcountersreceiver/testdata/scraper/metric_not_scraped.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
resourceMetrics: | ||
- resource: {} | ||
scopeMetrics: | ||
- metrics: | ||
- description: percentage of time CPU is idle. | ||
gauge: | ||
dataPoints: | ||
- asDouble: 0 | ||
timeUnixNano: "1646857199239674900" | ||
name: cpu.idle | ||
unit: '%' | ||
# Should not be present in the scrape output. | ||
# - name: no.counter | ||
scope: {} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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