Skip to content

Commit d5263a0

Browse files
ccressentmx-psi
andauthored
[exporter/sumologicexporter] Change Prometheus le label for infinity bounds (#39904)
#### Description For histograms, whenever a bound is (positive) infinity, give the Prometheus `le` label a string value of "+Inf". In all other cases, that label is set as a `double` value. #### Testing Unit tests. --------- Co-authored-by: Pablo Baeyens <[email protected]>
1 parent 06e825d commit d5263a0

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

.chloggen/otlp-inf-string.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: sumologicexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Change how infinity bounds are represented in histogram buckets so that the Sumologic backend can properly handle them.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39904]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

exporter/sumologicexporter/otlp.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ func getHistogramBucketsMetric(metric pmetric.Metric) pmetric.Metric {
8787
bucketDataPoint := bucketsDatapoints.AppendEmpty()
8888
bound := histogramBounds.At(j)
8989
histogramDataPoint.Attributes().CopyTo(bucketDataPoint.Attributes())
90-
bucketDataPoint.Attributes().PutDouble(prometheusLeTag, bound)
90+
91+
if math.IsInf(bound, 1) {
92+
bucketDataPoint.Attributes().PutStr(prometheusLeTag, prometheusInfValue)
93+
} else {
94+
bucketDataPoint.Attributes().PutDouble(prometheusLeTag, bound)
95+
}
96+
9197
bucketDataPoint.SetStartTimestamp(histogramDataPoint.StartTimestamp())
9298
bucketDataPoint.SetTimestamp(histogramDataPoint.Timestamp())
9399
cumulative += histogramDataPoint.BucketCounts().At(j)
@@ -97,7 +103,7 @@ func getHistogramBucketsMetric(metric pmetric.Metric) pmetric.Metric {
97103
// need to add one more bucket at +Inf
98104
bucketDataPoint := bucketsDatapoints.AppendEmpty()
99105
histogramDataPoint.Attributes().CopyTo(bucketDataPoint.Attributes())
100-
bucketDataPoint.Attributes().PutDouble(prometheusLeTag, math.Inf(1))
106+
bucketDataPoint.Attributes().PutStr(prometheusLeTag, prometheusInfValue)
101107
bucketDataPoint.SetStartTimestamp(histogramDataPoint.StartTimestamp())
102108
bucketDataPoint.SetTimestamp(histogramDataPoint.Timestamp())
103109
cumulative += histogramDataPoint.BucketCounts().At(histogramDataPoint.ExplicitBounds().Len())

exporter/sumologicexporter/otlp_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ func addExpectedHistogramBuckets(metrics pmetric.MetricSlice) {
142142
bound, bucketCount := pair.float64, pair.int64
143143
dataPoint := metric.Gauge().DataPoints().AppendEmpty()
144144
dataPoint.Attributes().PutStr("container", "dolor")
145-
dataPoint.Attributes().PutDouble(prometheusLeTag, bound)
145+
146+
if math.IsInf(bound, 1) {
147+
dataPoint.Attributes().PutStr(prometheusLeTag, prometheusInfValue)
148+
} else {
149+
dataPoint.Attributes().PutDouble(prometheusLeTag, bound)
150+
}
151+
146152
dataPoint.SetTimestamp(timestamp1)
147153
dataPoint.SetIntValue(bucketCount)
148154
}
@@ -162,7 +168,13 @@ func addExpectedHistogramBuckets(metrics pmetric.MetricSlice) {
162168
bound, bucketCount := pair.float64, pair.int64
163169
dataPoint := metric.Gauge().DataPoints().AppendEmpty()
164170
dataPoint.Attributes().PutStr("container", "sit")
165-
dataPoint.Attributes().PutDouble(prometheusLeTag, bound)
171+
172+
if math.IsInf(bound, 1) {
173+
dataPoint.Attributes().PutStr(prometheusLeTag, prometheusInfValue)
174+
} else {
175+
dataPoint.Attributes().PutDouble(prometheusLeTag, bound)
176+
}
177+
166178
dataPoint.SetTimestamp(timestamp2)
167179
dataPoint.SetIntValue(bucketCount)
168180
}

0 commit comments

Comments
 (0)