Skip to content

Commit

Permalink
Merge pull request #4 from zeno-splunk/fix-metric
Browse files Browse the repository at this point in the history
[chore]Fix metrics in kafkametricsreceiver (open-telemetry#4327)
  • Loading branch information
ZenoCC-Peng authored Jun 14, 2023
2 parents d007d69 + fc3172e commit ab1629e
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ 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".
subtext: Update metrics type in KafkaMetricsReceiver from "gauge" to "nonmonotonic sum".
24 changes: 12 additions & 12 deletions receiver/kafkametricsreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ Current approximate sum of consumer group lag across all partitions of topic
Count of members in the consumer group
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {members} | Gauge | Int |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {members} | Sum | Int | Delta | false |
#### Attributes
Expand Down Expand Up @@ -130,9 +130,9 @@ Oldest offset of partition of topic
Number of replicas for partition of topic
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {replicas} | Gauge | Int |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {replicas} | Sum | Int | Delta | false |
#### Attributes
Expand All @@ -145,9 +145,9 @@ Number of replicas for partition of topic
Number of synchronized replicas of partition
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {replicas} | Gauge | Int |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {replicas} | Sum | Int | Delta | false |
#### Attributes
Expand All @@ -160,9 +160,9 @@ Number of synchronized replicas of partition
Number of partitions in topic.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {partitions} | Gauge | Int |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {partitions} | Sum | Int | Delta | false |
#### Attributes
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.

16 changes: 12 additions & 4 deletions receiver/kafkametricsreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ metrics:
enabled: true
description: Number of partitions in topic.
unit: "{partitions}"
gauge:
sum:
monotonic: false
value_type: int
aggregation: delta
attributes: [topic]
kafka.partition.current_offset:
enabled: true
Expand All @@ -53,23 +55,29 @@ metrics:
enabled: true
description: Number of replicas for partition of topic
unit: "{replicas}"
gauge:
sum:
monotonic: false
value_type: int
aggregation: delta
attributes: [topic, partition]
kafka.partition.replicas_in_sync:
enabled: true
description: Number of synchronized replicas of partition
unit: "{replicas}"
gauge:
sum:
monotonic: false
value_type: int
aggregation: delta
attributes: [topic, partition]
# consumers scraper
kafka.consumer_group.members:
enabled: true
description: Count of members in the consumer group
unit: "{members}"
gauge:
sum:
monotonic: false
value_type: int
aggregation: delta
attributes: [group]
kafka.consumer_group.offset:
enabled: true
Expand Down
11 changes: 5 additions & 6 deletions receiver/kafkametricsreceiver/topic_scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,17 @@ func TestTopicScraper_scrapes(t *testing.T) {
ms := md.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics()
for i := 0; i < ms.Len(); i++ {
m := ms.At(i)
dp := m.Gauge().DataPoints().At(0)
switch m.Name() {
case "kafka.topic.partitions":
assert.Equal(t, dp.IntValue(), int64(len(testPartitions)))
assert.Equal(t, m.Sum().DataPoints().At(0).IntValue(), int64(len(testPartitions)))
case "kafka.partition.current_offset":
assert.Equal(t, dp.IntValue(), testOffset)
assert.Equal(t, m.Gauge().DataPoints().At(0).IntValue(), testOffset)
case "kafka.partition.oldest_offset":
assert.Equal(t, dp.IntValue(), testOffset)
assert.Equal(t, m.Gauge().DataPoints().At(0).IntValue(), testOffset)
case "kafka.partition.replicas":
assert.Equal(t, dp.IntValue(), int64(len(testReplicas)))
assert.Equal(t, m.Sum().DataPoints().At(0).IntValue(), int64(len(testReplicas)))
case "kafka.partition.replicas_in_sync":
assert.Equal(t, dp.IntValue(), int64(len(testReplicas)))
assert.Equal(t, m.Sum().DataPoints().At(0).IntValue(), int64(len(testReplicas)))
}
}
}
Expand Down

0 comments on commit ab1629e

Please sign in to comment.