Skip to content

Commit

Permalink
Prometheus fix inf bucket count (open-telemetry#15287)
Browse files Browse the repository at this point in the history
 +Inf bucket counts are handled incorrectly in both prometheusexporter and prometheusremotewriteexporter.
  • Loading branch information
balintzs authored and shalper2 committed Dec 6, 2022
1 parent 09c870a commit 8ed193b
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 16 deletions.
11 changes: 11 additions & 0 deletions .chloggen/prometheus-fix-inf-bucket-count.yaml
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: prometheusremotewriteexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix value of `+Inf` histogram bucket to be equal to total count

# One or more tracking issues related to the change
issues: [4975]
2 changes: 1 addition & 1 deletion cmd/configschema/go.mod
Expand Up @@ -511,7 +511,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_golang v1.13.1-0.20221013115219-dcea97eee2b3 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion cmd/configschema/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion exporter/prometheusexporter/go.mod
Expand Up @@ -7,7 +7,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.62.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus v0.62.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.62.0
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_golang v1.13.1-0.20221013115219-dcea97eee2b3
github.com/prometheus/client_model v0.3.0
github.com/prometheus/common v0.37.0
github.com/prometheus/prometheus v0.38.0
Expand Down
4 changes: 2 additions & 2 deletions exporter/prometheusexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -511,7 +511,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_golang v1.13.1-0.20221013115219-dcea97eee2b3 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions pkg/translator/prometheusremotewrite/helper.go
Expand Up @@ -344,10 +344,7 @@ func addSingleHistogramDataPoint(pt pmetric.HistogramDataPoint, resource pcommon
if pt.Flags().NoRecordedValue() {
infBucket.Value = math.Float64frombits(value.StaleNaN)
} else {
if pt.BucketCounts().Len() > 0 {
cumulativeCount += pt.BucketCounts().At(pt.BucketCounts().Len() - 1)
}
infBucket.Value = float64(cumulativeCount)
infBucket.Value = float64(pt.Count())
}
infLabels := createAttributes(resource, pt.Attributes(), settings.ExternalLabels, nameStr, baseName+bucketStr, leStr, pInfStr)
sig := addSample(tsMap, infBucket, infLabels, metric.Type().String())
Expand Down
2 changes: 1 addition & 1 deletion processor/spanmetricsprocessor/go.mod
Expand Up @@ -58,7 +58,7 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_golang v1.13.1-0.20221013115219-dcea97eee2b3 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions processor/spanmetricsprocessor/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testbed/go.mod
Expand Up @@ -165,7 +165,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_golang v1.13.1-0.20221013115219-dcea97eee2b3 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion testbed/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8ed193b

Please sign in to comment.