Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/kafkametrics] Fix metrics in kafkametricsreceiver (#4327) #23332

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unnecessary removal of the training line. Usually, linters complain about not having them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understand.
This stems from an IDE, I think I should not enable autoformatting.

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