Skip to content

Commit ab42d69

Browse files
authored
[receiver/kafkametrics] Fix metrics in kafkametricsreceiver (open-telemetry#4327) (open-telemetry#23332)
Update `kafka.brokers` metric to be non-monothonic sum instead of gauge
1 parent 9e4d50f commit ab42d69

File tree

7 files changed

+45
-18
lines changed

7 files changed

+45
-18
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use this changelog template to create an entry for release notes.
2+
# If your change doesn't affect end users, such as a test fix or a tooling change,
3+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
4+
5+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
6+
change_type: bug_fix
7+
8+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
9+
component: receiver/kafkametricsreceiver
10+
11+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
12+
note: Updates certain metrics in kafkametricsreceiver to function as non-monotonic sums.
13+
14+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
15+
issues: [4327]
16+
17+
# (Optional) One or more lines of additional information to render under the primary note.
18+
# These lines will be padded with 2 spaces and then inserted directly into the document.
19+
# Use pipe (|) for multiline entries.
20+
subtext: Update the metric type in KafkaMetricsReceiver from "gauge" to "nonmonotonic sum".

receiver/kafkametricsreceiver/broker_scraper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestBrokerScraper_scrape(t *testing.T) {
106106
assert.NoError(t, err)
107107
expectedDp := int64(len(testBrokers))
108108
receivedMetrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
109-
receivedDp := receivedMetrics.Gauge().DataPoints().At(0).IntValue()
109+
receivedDp := receivedMetrics.Sum().DataPoints().At(0).IntValue()
110110
assert.Equal(t, expectedDp, receivedDp)
111111
}
112112

receiver/kafkametricsreceiver/documentation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ metrics:
1616
1717
Number of brokers in the cluster.
1818
19-
| Unit | Metric Type | Value Type |
20-
| ---- | ----------- | ---------- |
21-
| {brokers} | Gauge | Int |
19+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
20+
| ---- | ----------- | ---------- | ----------------------- | --------- |
21+
| {brokers} | Sum | Int | Delta | false |
2222
2323
### kafka.consumer_group.lag
2424

receiver/kafkametricsreceiver/internal/metadata/generated_metrics.go

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/kafkametricsreceiver/internal/metadata/generated_metrics_test.go

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/kafkametricsreceiver/metadata.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ attributes:
1818
type: string
1919

2020
metrics:
21-
# brokers scraper
21+
# brokers scraper
2222
kafka.brokers:
2323
enabled: true
2424
description: Number of brokers in the cluster.
2525
unit: "{brokers}"
26-
gauge:
26+
sum:
27+
monotonic: false
2728
value_type: int
28-
# topics scraper
29+
aggregation: delta
30+
# topics scraper
2931
kafka.topic.partitions:
3032
enabled: true
3133
description: Number of partitions in topic.
@@ -61,7 +63,7 @@ metrics:
6163
gauge:
6264
value_type: int
6365
attributes: [topic, partition]
64-
# consumers scraper
66+
# consumers scraper
6567
kafka.consumer_group.members:
6668
enabled: true
6769
description: Count of members in the consumer group
@@ -96,4 +98,4 @@ metrics:
9698
unit: 1
9799
gauge:
98100
value_type: int
99-
attributes: [group, topic]
101+
attributes: [group, topic]

receiver/kafkametricsreceiver/testdata/integration/expected.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ resourceMetrics:
33
scopeMetrics:
44
- metrics:
55
- description: Number of brokers in the cluster.
6-
gauge:
6+
sum:
7+
aggregationTemporality: 1
78
dataPoints:
89
- asInt: "1"
910
startTimeUnixNano: "1685063120199110000"

0 commit comments

Comments
 (0)