Repository navigation
fix(metrics): skip unsupported Prometheus metric types - #1384
Closed
MartinForReal wants to merge 1 commit into
Closed
MartinForReal wants to merge 1 commit into
MartinForReal wants to merge 1 commit into
Conversation
ParsePrometheusMetrics currently fails the whole parse when a scrape contains a metric family type it does not handle. A Prometheus exposition may contain a sample without a # TYPE line, which the text parser reports as UNTYPED, so one such family currently breaks parsing of every other metric in the scrape. Return only the family types this helper supports. COUNTER, GAUGE, SUMMARY, and HISTOGRAM handling is unchanged, and malformed exposition still returns an error. Add regression tests for explicit and implicit UNTYPED families and for SUMMARY/HISTOGRAM sample sums.
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MartinForReal The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Member
Author
|
Closing as requested. The remaining parsing fix is not being pursued in this PR. |
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 type of PR is this?
/kind bug
What this PR does / why we need it:
This replaces the stale #1210. Current master already uses OpenTelemetry: #1297 merged the OpenCensus -> OpenTelemetry metrics migration, and the remaining OpenCensus references are historical comments. The original #1210 branch was therefore reduced to the one behavior on top of current master that is still missing.
ParsePrometheusMetrics(used by the e2e helper that scrapes NPD/metrics) currently returns an error for any family type it does not recognize. A Prometheus exposition may contain a sample without a# TYPEline; the text parser reports that family asUNTYPED. One such family therefore fails parsing of the whole scrape, even when all NPD counters/gauges parsed successfully.This PR makes
ParsePrometheusMetricsskip family types it does not support instead of aborting, while keeping the existing handling:COUNTERandGAUGEvalues;SUMMARYsample sums;HISTOGRAMsample sums.Malformed exposition (bad labels, duplicate
TYPElines, trailing garbage) still returns a parse error.Which issue(s) this PR fixes:
Refs #1008. The migration itself landed in #1297; this PR remains as a parsing robustness fix discovered during that migration. Refs #1210 for history.
Special notes for your reviewer:
Changes
pkg/util/metrics/helpers.go: unsupported family types are skipped, and the function documentation states which family types are returned.pkg/util/metrics/helpers_test.go: table tests cover explicitUNTYPEDand implicit (noTYPE) families, and pin SUMMARY/HISTOGRAM sample sums.Behavior
No change to the metrics NPD emits, its metric names, labels, or OpenTelemetry configuration. The change only affects parsing of Prometheus text by this helper.
Validation
test/e2esuites): pass.pkg/util/metrics/...,pkg/exporters/...,pkg/problemmetrics/...): pass, andgo vetpasses.go.mod,go.sum,vendor/: unchanged relative to upstream master.Does this PR introduce a user-facing change?