Skip to content

Commit eef8c17

Browse files
author
Sam DeHaan
authored
Update Kafka JMX Script (#216)
* Enhance kafka * Appease spotless * Remove another test from integration for now * Remove another metric not available in integration test * Fix documentation * Fix expected type of election metrics * Fix issues with integration tests * Update decription of metric in expected * Resolve PR feedback * Fix accidental commit of local files * Address PR feedback * Update the way kafka producer container is loaded for multiple tests * Update docs to reflect removal of topic attributes
1 parent 83f8bcd commit eef8c17

File tree

4 files changed

+382
-375
lines changed

4 files changed

+382
-375
lines changed

jmx-metrics/docs/target-systems/kafka.md

Lines changed: 68 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,116 +7,104 @@ These metrics are sourced from Kafka's exposed Yammer metrics for each instance:
77

88
### Broker Metrics
99

10-
* Name: `kafka.messages.in`
11-
* Description: Number of messages in per second
12-
* Unit: `1`
13-
* Instrument Type: LongValueObserver
10+
* Name: `kafka.message.count`
11+
* Description: The number of messages received by the broker
12+
* Unit: `{messages}`
13+
* Instrument Type: LongCounterObserver
14+
15+
* Name: `kafka.request.count`
16+
* Description: The number of requests received by the broker
17+
* Unit: `{requests}`
18+
* Attributes: `type`
19+
* Instrument Type: LongCounterObserver
20+
21+
* Name: `kafka.request.failed`
22+
* Description: The number of requests to the broker resulting in a failure
23+
* Unit: `{requests}`
24+
* Attributes: `type`
25+
* Instrument Type: LongCounterObserver
26+
27+
* Name: `kafka.request.time.total`
28+
* Description: The total time the broker has taken to service requests
29+
* Unit: `ms`
30+
* Attributes: `type`
31+
* Instrument Type: LongCounterObserver
32+
33+
* Name: `kafka.request.time.50p`
34+
* Description: The 50th percentile time the broker has taken to service requests
35+
* Unit: `ms`
36+
* Attributes: `type`
37+
* Instrument Type: DoubleValueObserver
1438

15-
* Name: `kafka.bytes.in`
16-
* Description: Bytes in per second from clients
39+
* Name: `kafka.request.time.99p`
40+
* Description: The 99th percentile time the broker has taken to service requests
41+
* Unit: `ms`
42+
* Attributes: `type`
43+
* Instrument Type: DoubleValueObserver
44+
45+
* Name: `kafka.network.io`
46+
* Description: The bytes received or sent by the broker
1747
* Unit: `by`
48+
* Attributes: `state`
49+
* Instrument Type: LongCounterObserver
50+
51+
* Name: `kafka.purgatory.size`
52+
* Description: The number of requests waiting in purgatory
53+
* Unit: `{requests}`
54+
* Attributes: `type`
1855
* Instrument Type: LongValueObserver
1956

20-
* Name: `kafka.bytes.out`
21-
* Description: Bytes out per second to clients
22-
* Unit: `by`
57+
* Name: `kafka.partition.count`
58+
* Description: The number of partitions on the broker
59+
* Unit: `{partitions}`
2360
* Instrument Type: LongValueObserver
2461

25-
* Name: `kafka.isr.shrinks`
26-
* Description: In-sync replica shrinks per second
27-
* Unit: `1`
62+
* Name: `kafka.partition.offline`
63+
* Description: The number of partitions offline
64+
* Unit: `{partitions}`
2865
* Instrument Type: LongValueObserver
2966

30-
* Name: `kafka.isr.expands`
31-
* Description: In-sync replica expands per second
32-
* Unit: `1`
67+
* Name: `kafka.partition.under_replicated`
68+
* Description: The number of under replicated partitions
69+
* Unit: `{partitions}`
3370
* Instrument Type: LongValueObserver
3471

72+
* Name: `kafka.isr.operation.count`
73+
* Description: The number of in-sync replica shrink and expand operations
74+
* Unit: `{operations}`
75+
* Attributes: `operation`
76+
* Instrument Type: LongCounterObserver
77+
3578
* Name: `kafka.max.lag`
3679
* Description: Max lag in messages between follower and leader replicas
37-
* Unit: `1`
80+
* Unit: `{messages}`
3881
* Instrument Type: LongValueObserver
3982

4083
* Name: `kafka.controller.active.count`
4184
* Description: Controller is active on broker
42-
* Unit: `1`
43-
* Instrument Type: LongValueObserver
44-
45-
* Name: `kafka.partitions.offline.count`
46-
* Description: Number of partitions without an active leader
47-
* Unit: `1`
48-
* Instrument Type: LongValueObserver
49-
50-
* Name: `kafka.partitions.underreplicated.count`
51-
* Description: Number of under replicated partitions
52-
* Unit: `1`
85+
* Unit: `{controllers}`
5386
* Instrument Type: LongValueObserver
5487

5588
* Name: `kafka.leader.election.rate`
56-
* Description: Leader election rate - non-zero indicates broker failures
57-
* Unit: `1`
58-
* Instrument Type: LongValueObserver
89+
* Description: Leader election rate - increasing indicates broker failures
90+
* Unit: `{elections}`
91+
* Instrument Type: LongCounterObserver
5992

6093
* Name: `kafka.unclean.election.rate`
61-
* Description: Unclean leader election rate - non-zero indicates broker failures
62-
* Unit: `1`
63-
* Instrument Type: LongValueObserver
94+
* Description: Unclean leader election rate - increasing indicates broker failures
95+
* Unit: `{elections}`
96+
* Instrument Type: LongCounterObserver
6497

6598
* Name: `kafka.request.queue`
6699
* Description: Size of the request queue
67-
* Unit: `1`
100+
* Unit: `{requests}`
68101
* Instrument Type: LongValueObserver
69102

70-
* Name: `kafka.fetch.consumer.total.time.count`
71-
* Description: Fetch consumer request count
72-
* Unit: `1`
73-
* Instrument Type: LongSumObserver
74-
75-
* Name: `kafka.fetch.consumer.total.time.median`
76-
* Description: Fetch consumer request time - 50th percentile
77-
* Unit: `ms`
78-
* Instrument Type: DoubleValueObserver
79-
80-
* Name: `kafka.fetch.consumer.total.time.99p`
81-
* Description: Fetch consumer request time - 99th percentile
82-
* Unit: `ms`
83-
* Instrument Type: DoubleValueObserver
84-
85-
* Name: `kafka.fetch.follower.total.time.count`
86-
* Description: Fetch follower request count
87-
* Unit: `1`
88-
* Instrument Type: LongSumObserver
89-
90-
* Name: `kafka.fetch.follower.total.time.median`
91-
* Description: Fetch follower request time - 50th percentile
92-
* Unit: `ms`
93-
* Instrument Type: DoubleValueObserver
94-
95-
* Name: `kafka.fetch.follower.total.time.99p`
96-
* Description: Fetch follower request time - 99th percentile
97-
* Unit: `ms`
98-
* Instrument Type: DoubleValueObserver
99-
100-
* Name: `kafka.produce.total.time.count`
101-
* Description: Produce request count
102-
* Unit: `1`
103-
* Instrument Type: LongSumObserver
104-
105-
* Name: `kafka.produce.total.time.median`
106-
* Description: Produce request time - 50th percentile
107-
* Unit: `ms`
108-
* Instrument Type: DoubleValueObserver
109-
110-
* Name: `kafka.produce.total.time.99p`
111-
* Description: Produce request time - 99th percentile
112-
* Unit: `ms`
113-
* Instrument Type: DoubleValueObserver
114-
115103
### Log metrics
116104

117105
* Name: `kafka.logs.flush.time.count`
118106
* Description: Log flush count
119-
* Unit: `1`
107+
* Unit: `ms`
120108
* Instrument Type: LongSumObserver
121109

122110
* Name: `kafka.logs.flush.time.median`

jmx-metrics/src/integrationTest/java/io/opentelemetry/contrib/jmxmetrics/AbstractIntegrationTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ protected static GenericContainer<?> cassandraContainer() {
125125
.waitingFor(Wait.forLogMessage(".*Startup complete.*", 1));
126126
}
127127

128-
@SafeVarargs
129-
protected final void waitAndAssertMetrics(Consumer<Metric>... assertions) {
128+
protected final void waitAndAssertMetrics(Iterable<Consumer<Metric>> assertions) {
130129
await()
131130
.atMost(Duration.ofSeconds(30))
132131
.untilAsserted(
@@ -158,6 +157,12 @@ protected final void waitAndAssertMetrics(Consumer<Metric>... assertions) {
158157
});
159158
}
160159

160+
@SafeVarargs
161+
@SuppressWarnings("varargs")
162+
protected final void waitAndAssertMetrics(Consumer<Metric>... assertions) {
163+
waitAndAssertMetrics(Arrays.asList(assertions));
164+
}
165+
161166
protected void assertGauge(Metric metric, String name, String description, String unit) {
162167
assertThat(metric.getName()).isEqualTo(name);
163168
assertThat(metric.getDescription()).isEqualTo(description);

0 commit comments

Comments
 (0)