Skip to content

Commit

Permalink
[receiver/kafkametrics] Fix metrics in kafkametricsreceiver (open-tel…
Browse files Browse the repository at this point in the history
…emetry#4327) (open-telemetry#23332)

Update `kafka.brokers` metric to be non-monothonic sum instead of gauge
  • Loading branch information
ZenoCC-Peng authored Jun 13, 2023
1 parent 9e4d50f commit ab42d69
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 18 deletions.
20 changes: 20 additions & 0 deletions .chloggen/fix-kafkametric-receiver-type.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# 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: receiver/kafkametricsreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Updates certain metrics in kafkametricsreceiver to function as non-monotonic sums.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [4327]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: Update the metric type in KafkaMetricsReceiver from "gauge" to "nonmonotonic sum".
2 changes: 1 addition & 1 deletion receiver/kafkametricsreceiver/broker_scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestBrokerScraper_scrape(t *testing.T) {
assert.NoError(t, err)
expectedDp := int64(len(testBrokers))
receivedMetrics := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
receivedDp := receivedMetrics.Gauge().DataPoints().At(0).IntValue()
receivedDp := receivedMetrics.Sum().DataPoints().At(0).IntValue()
assert.Equal(t, expectedDp, receivedDp)
}

Expand Down
6 changes: 3 additions & 3 deletions receiver/kafkametricsreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ metrics:
Number of brokers in the cluster.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {brokers} | Gauge | Int |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {brokers} | Sum | Int | Delta | false |
### kafka.consumer_group.lag
Expand Down

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

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

12 changes: 7 additions & 5 deletions receiver/kafkametricsreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ attributes:
type: string

metrics:
# brokers scraper
# brokers scraper
kafka.brokers:
enabled: true
description: Number of brokers in the cluster.
unit: "{brokers}"
gauge:
sum:
monotonic: false
value_type: int
# topics scraper
aggregation: delta
# topics scraper
kafka.topic.partitions:
enabled: true
description: Number of partitions in topic.
Expand Down Expand Up @@ -61,7 +63,7 @@ metrics:
gauge:
value_type: int
attributes: [topic, partition]
# consumers scraper
# consumers scraper
kafka.consumer_group.members:
enabled: true
description: Count of members in the consumer group
Expand Down Expand Up @@ -96,4 +98,4 @@ metrics:
unit: 1
gauge:
value_type: int
attributes: [group, topic]
attributes: [group, topic]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ resourceMetrics:
scopeMetrics:
- metrics:
- description: Number of brokers in the cluster.
gauge:
sum:
aggregationTemporality: 1
dataPoints:
- asInt: "1"
startTimeUnixNano: "1685063120199110000"
Expand Down

0 comments on commit ab42d69

Please sign in to comment.