Skip to content

Commit 9f47008

Browse files
Adopt asynchronous helpers in Kafka target script (#23)
1 parent 6704450 commit 9f47008

File tree

3 files changed

+85
-71
lines changed

3 files changed

+85
-71
lines changed

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,121 +10,121 @@ These metrics are sourced from Kafka's exposed Yammer metrics for each instance:
1010
* Name: `kafka.messages.in`
1111
* Description: Number of messages in per second
1212
* Unit: `1`
13-
* Instrument Type: LongCounter
13+
* Instrument Type: LongValueObserver
1414

1515
* Name: `kafka.bytes.in`
1616
* Description: Bytes in per second from clients
1717
* Unit: `by`
18-
* Instrument Type: LongCounter
18+
* Instrument Type: LongValueObserver
1919

2020
* Name: `kafka.bytes.out`
2121
* Description: Bytes out per second to clients
2222
* Unit: `by`
23-
* Instrument Type: LongCounter
23+
* Instrument Type: LongValueObserver
2424

2525
* Name: `kafka.isr.shrinks`
2626
* Description: In-sync replica shrinks per second
2727
* Unit: `1`
28-
* Instrument Type: LongCounter
28+
* Instrument Type: LongValueObserver
2929

3030
* Name: `kafka.isr.expands`
3131
* Description: In-sync replica expands per second
3232
* Unit: `1`
33-
* Instrument Type: LongCounter
33+
* Instrument Type: LongValueObserver
3434

3535
* Name: `kafka.max.lag`
3636
* Description: Max lag in messages between follower and leader replicas
3737
* Unit: `1`
38-
* Instrument Type: LongUpDownCounter
38+
* Instrument Type: LongValueObserver
3939

4040
* Name: `kafka.controller.active.count`
4141
* Description: Controller is active on broker
4242
* Unit: `1`
43-
* Instrument Type: LongUpDownCounter
43+
* Instrument Type: LongValueObserver
4444

4545
* Name: `kafka.partitions.offline.count`
4646
* Description: Number of partitions without an active leader
4747
* Unit: `1`
48-
* Instrument Type: LongUpDownCounter
48+
* Instrument Type: LongValueObserver
4949

5050
* Name: `kafka.partitions.underreplicated.count`
5151
* Description: Number of under replicated partitions
5252
* Unit: `1`
53-
* Instrument Type: LongUpDownCounter
53+
* Instrument Type: LongValueObserver
5454

5555
* Name: `kafka.leader.election.rate`
5656
* Description: Leader election rate - non-zero indicates broker failures
5757
* Unit: `1`
58-
* Instrument Type: LongCounter
58+
* Instrument Type: LongValueObserver
5959

6060
* Name: `kafka.unclean.election.rate`
6161
* Description: Unclean leader election rate - non-zero indicates broker failures
6262
* Unit: `1`
63-
* Instrument Type: LongCounter
63+
* Instrument Type: LongValueObserver
6464

6565
* Name: `kafka.request.queue`
6666
* Description: Size of the request queue
6767
* Unit: `1`
68-
* Instrument Type: LongUpDownCounter
68+
* Instrument Type: LongValueObserver
6969

7070
* Name: `kafka.fetch.consumer.total.time.count`
7171
* Description: Fetch consumer request count
7272
* Unit: `1`
73-
* Instrument Type: LongCounter
73+
* Instrument Type: LongSumObserver
7474

7575
* Name: `kafka.fetch.consumer.total.time.median`
7676
* Description: Fetch consumer request time - 50th percentile
7777
* Unit: `ms`
78-
* Instrument Type: DoubleUpDownCounter
78+
* Instrument Type: DoubleValueObserver
7979

8080
* Name: `kafka.fetch.consumer.total.time.99p`
8181
* Description: Fetch consumer request time - 99th percentile
8282
* Unit: `ms`
83-
* Instrument Type: DoubleUpDownCounter
83+
* Instrument Type: DoubleValueObserver
8484

8585
* Name: `kafka.fetch.follower.total.time.count`
8686
* Description: Fetch follower request count
8787
* Unit: `1`
88-
* Instrument Type: LongCounter
88+
* Instrument Type: LongSumObserver
8989

9090
* Name: `kafka.fetch.follower.total.time.median`
9191
* Description: Fetch follower request time - 50th percentile
9292
* Unit: `ms`
93-
* Instrument Type: DoubleUpDownCounter
93+
* Instrument Type: DoubleValueObserver
9494

9595
* Name: `kafka.fetch.follower.total.time.99p`
9696
* Description: Fetch follower request time - 99th percentile
9797
* Unit: `ms`
98-
* Instrument Type: DoubleUpDownCounter
98+
* Instrument Type: DoubleValueObserver
9999

100100
* Name: `kafka.produce.total.time.count`
101101
* Description: Produce request count
102102
* Unit: `1`
103-
* Instrument Type: LongCounter
103+
* Instrument Type: LongSumObserver
104104

105105
* Name: `kafka.produce.total.time.median`
106106
* Description: Produce request time - 50th percentile
107107
* Unit: `ms`
108-
* Instrument Type: DoubleUpDownCounter
108+
* Instrument Type: DoubleValueObserver
109109

110110
* Name: `kafka.produce.total.time.99p`
111111
* Description: Produce request time - 99th percentile
112112
* Unit: `ms`
113-
* Instrument Type: DoubleUpDownCounter
113+
* Instrument Type: DoubleValueObserver
114114

115115
### Log metrics
116116

117117
* Name: `kafka.logs.flush.time.count`
118118
* Description: Log flush count
119119
* Unit: `1`
120-
* Instrument Type: LongCounter
120+
* Instrument Type: LongSumObserver
121121

122122
* Name: `kafka.logs.flush.time.median`
123123
* Description: Log flush time - 50th percentile
124124
* Unit: `ms`
125-
* Instrument Type: DoubleUpDownCounter
125+
* Instrument Type: DoubleValueObserver
126126

127127
* Name: `kafka.logs.flush.time.99p`
128128
* Description: Log flush time - 99th percentile
129129
* Unit: `ms`
130-
* Instrument Type: DoubleUpDownCounter
130+
* Instrument Type: DoubleValueObserver

contrib/jmx-metrics/src/main/resources/target-systems/kafka.groovy

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,80 +16,80 @@
1616

1717
def messagesInPerSec = otel.mbean("kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec")
1818
otel.instrument(messagesInPerSec, "kafka.messages.in", "number of messages in per second",
19-
"1", "Count", otel.&longCounter)
19+
"1", "Count", otel.&longValueObserver)
2020

2121
def bytesInPerSec = otel.mbean("kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec")
2222
otel.instrument(bytesInPerSec, "kafka.bytes.in", "bytes in per second from clients",
23-
"by", "Count", otel.&longCounter)
23+
"by", "Count", otel.&longValueObserver)
2424

2525
def bytesOutPerSec = otel.mbean("kafka.server:type=BrokerTopicMetrics,name=BytesOutPerSec")
2626
otel.instrument(bytesOutPerSec, "kafka.bytes.out", "bytes out per second to clients",
27-
"by", "Count", otel.&longCounter)
27+
"by", "Count", otel.&longValueObserver)
2828

2929
def isrShrinksPerSec = otel.mbean("kafka.server:type=ReplicaManager,name=IsrShrinksPerSec")
3030
otel.instrument(isrShrinksPerSec, "kafka.isr.shrinks", "in-sync replica shrinks per second",
31-
"1", "Count", otel.&longCounter)
31+
"1", "Count", otel.&longValueObserver)
3232

3333
def isrExpandsPerSec = otel.mbean("kafka.server:type=ReplicaManager,name=IsrExpandsPerSec")
3434
otel.instrument(isrExpandsPerSec, "kafka.isr.expands", "in-sync replica expands per second",
35-
"1", "Count", otel.&longCounter)
35+
"1", "Count", otel.&longValueObserver)
3636

3737
def maxLag = otel.mbean("kafka.server:type=ReplicaFetcherManager,name=MaxLag,clientId=Replica")
3838
otel.instrument(maxLag, "kafka.max.lag", "max lag in messages between follower and leader replicas",
39-
"1", "Value", otel.&longUpDownCounter)
39+
"1", "Value", otel.&longValueObserver)
4040

4141
def activeControllerCount = otel.mbean("kafka.controller:type=KafkaController,name=ActiveControllerCount")
4242
otel.instrument(activeControllerCount, "kafka.controller.active.count", "controller is active on broker",
43-
"1", "Value", otel.&longUpDownCounter)
43+
"1", "Value", otel.&longValueObserver)
4444

4545
def offlinePartitionsCount = otel.mbean("kafka.controller:type=KafkaController,name=OfflinePartitionsCount")
4646
otel.instrument(offlinePartitionsCount, "kafka.partitions.offline.count", "number of partitions without an active leader",
47-
"1", "Value", otel.&longUpDownCounter)
47+
"1", "Value", otel.&longValueObserver)
4848

4949
def underReplicatedPartitionsCount = otel.mbean("kafka.server:type=ReplicaManager,name=UnderReplicatedPartitions")
5050
otel.instrument(underReplicatedPartitionsCount, "kafka.partitions.underreplicated.count", "number of under replicated partitions",
51-
"1", "Value", otel.&longUpDownCounter)
51+
"1", "Value", otel.&longValueObserver)
5252

5353
def leaderElectionRate = otel.mbean("kafka.controller:type=ControllerStats,name=LeaderElectionRateAndTimeMs")
5454
otel.instrument(leaderElectionRate, "kafka.leader.election.rate", "leader election rate - non-zero indicates broker failures",
55-
"1", "Count", otel.&longCounter)
55+
"1", "Count", otel.&longValueObserver)
5656

5757
def uncleanLeaderElections = otel.mbean("kafka.controller:type=ControllerStats,name=UncleanLeaderElectionsPerSec")
5858
otel.instrument(uncleanLeaderElections, "kafka.unclean.election.rate", "unclean leader election rate - non-zero indicates broker failures",
59-
"1", "Count", otel.&longCounter)
59+
"1", "Count", otel.&longValueObserver)
6060

6161
def requestQueueSize = otel.mbean("kafka.network:type=RequestChannel,name=RequestQueueSize")
6262
otel.instrument(requestQueueSize, "kafka.request.queue", "size of the request queue",
63-
"1", "Value", otel.&longUpDownCounter)
63+
"1", "Value", otel.&longValueObserver)
6464

6565
def fetchConsumer = otel.mbean("kafka.network:type=RequestMetrics,name=TotalTimeMs,request=FetchConsumer")
6666
otel.instrument(fetchConsumer, "kafka.fetch.consumer.total.time.count", "fetch consumer request count",
67-
"1", "Count", otel.&longCounter)
67+
"1", "Count", otel.&longSumObserver)
6868
otel.instrument(fetchConsumer, "kafka.fetch.consumer.total.time.median", "fetch consumer request time - 50th percentile",
69-
"ms", "50thPercentile", otel.&doubleUpDownCounter)
69+
"ms", "50thPercentile", otel.&doubleValueObserver)
7070
otel.instrument(fetchConsumer, "kafka.fetch.consumer.total.time.99p", "fetch consumer request time - 99th percentile",
71-
"ms", "99thPercentile", otel.&doubleUpDownCounter)
71+
"ms", "99thPercentile", otel.&doubleValueObserver)
7272

7373
def fetchFollower = otel.mbean("kafka.network:type=RequestMetrics,name=TotalTimeMs,request=FetchFollower")
7474
otel.instrument(fetchFollower, "kafka.fetch.follower.total.time.count", "fetch follower request count",
75-
"1", "Count", otel.&longCounter)
75+
"1", "Count", otel.&longSumObserver)
7676
otel.instrument(fetchFollower, "kafka.fetch.follower.total.time.median", "fetch follower request time - 50th percentile",
77-
"ms", "50thPercentile", otel.&doubleUpDownCounter)
77+
"ms", "50thPercentile", otel.&doubleValueObserver)
7878
otel.instrument(fetchFollower, "kafka.fetch.follower.total.time.99p", "fetch follower request time - 99th percentile",
79-
"ms", "99thPercentile", otel.&doubleUpDownCounter)
79+
"ms", "99thPercentile", otel.&doubleValueObserver)
8080

8181
def produce = otel.mbean("kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Produce")
8282
otel.instrument(produce, "kafka.produce.total.time.count", "produce request count",
83-
"1", "Count", otel.&longCounter)
83+
"1", "Count", otel.&longSumObserver)
8484
otel.instrument(produce, "kafka.produce.total.time.median", "produce request time - 50th percentile",
85-
"ms", "50thPercentile", otel.&doubleUpDownCounter)
85+
"ms", "50thPercentile", otel.&doubleValueObserver)
8686
otel.instrument(produce, "kafka.produce.total.time.99p", "produce request time - 99th percentile",
87-
"ms", "99thPercentile", otel.&doubleUpDownCounter)
87+
"ms", "99thPercentile", otel.&doubleValueObserver)
8888

8989
def logFlushRate = otel.mbean("kafka.log:type=LogFlushStats,name=LogFlushRateAndTimeMs")
9090
otel.instrument(logFlushRate, "kafka.logs.flush.time.count", "log flush count",
91-
"1", "Count", otel.&longCounter)
91+
"1", "Count", otel.&longSumObserver)
9292
otel.instrument(logFlushRate, "kafka.logs.flush.time.median", "log flush time - 50th percentile",
93-
"ms", "50thPercentile", otel.&doubleUpDownCounter)
93+
"ms", "50thPercentile", otel.&doubleValueObserver)
9494
otel.instrument(logFlushRate, "kafka.logs.flush.time.99p", "log flush time - 99th percentile",
95-
"ms", "99thPercentile", otel.&doubleUpDownCounter)
95+
"ms", "99thPercentile", otel.&doubleValueObserver)

0 commit comments

Comments
 (0)