# Library instrumentation for Kafka Clients version 2.6 and higher

## Quickstart

### Add these dependencies to your project

Replace `OPENTELEMETRY_VERSION` with the [latest
release](https://search.maven.org/search?q=g:io.opentelemetry.instrumentation%20AND%20a:opentelemetry-kafka-clients-2.6).

For Maven, add to your `pom.xml` dependencies:

```xml
<dependencies>
  <dependency>
    <groupId>io.opentelemetry.instrumentation</groupId>
    <artifactId>opentelemetry-kafka-clients-2.6</artifactId>
    <version>OPENTELEMETRY_VERSION</version>
  </dependency>
</dependencies>
```

For Gradle, add to your dependencies:

```groovy
implementation("io.opentelemetry.instrumentation:opentelemetry-kafka-clients-2.6:OPENTELEMETRY_VERSION")
```

### Usage (Tracing)

There are two options for capturing traces, either using interceptors or wrapping clients, both described below.

#### Using interceptors

The Kafka clients API provides a way to "intercept" messages before they are sent to the brokers as well as messages received from the broker before being passed to the application.
The OpenTelemetry instrumented Kafka library provides two interceptors to be configured to add tracing information automatically.
The interceptor class has to be set in the properties bag used to create the Kafka client.

Use the `TracingProducerInterceptor` for the producer in order to create a "send" span automatically, each time a message is sent.

```java
props.setProperty(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, TracingProducerInterceptor.class.getName());
```

Use the `TracingConsumerInterceptor` for the consumer in order to create a "receive" span automatically, each time a message is received.

```java
props.setProperty(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, TracingConsumerInterceptor.class.getName());
```

#### Wrapping clients

The other way is by wrapping the Kafka client with a tracing enabled Kafka client.

Assuming you have a `Producer<K, V> producer` instance, you can wrap it in the following way.

```java
KafkaTelemetry telemetry = KafkaTelemetry.create(GlobalOpenTelemetry.get());
Producer<String, String> tracingProducer = telemetry.wrap(producer);
```

Then use the `tracingProducer` as usual for sending messages to the Kafka cluster.

Assuming you have a `Consumer<K, V> consumer` instance, you can wrap it in the following way.

```java
KafkaTelemetry telemetry = KafkaTelemetry.create(GlobalOpenTelemetry.get());
Consumer<String, String> tracingConsumer = telemetry.wrap(this.consumer);
```

Then use the `tracingConsumer` as usual for receiving messages from the Kafka cluster.

### Usage (Metrics)

The Kafka client exposes metrics via `org.apache.kafka.common.metrics.MetricsReporter` interface.
OpenTelemetry provides an implementation that bridges the metrics into OpenTelemetry.

To use, merge the config properties
from `KafkaTelemetry.create(OpenTelemetry).metricConfigProperties()`
with the configuration used when creating your producer or consumer.

Note: Kafka reports several metrics at multiple attribute granularities. For
example, `records-consumed-total` is reported with attribute key `[client-id]`
and `[client-id, topic]`. If you analyze the sum of records consumed, ignoring dimensions, backends
are likely to double count. The implementation detects this scenario and only records the most
granular set of attributes available. In the case
of `records-consumed-total`, it reports `[client-id, topic]` and ignores `[client-id]`.

The following table shows the full set of metrics exposed by the kafka client, and the corresponding
OpenTelemetry metric each maps to (if available). Empty values in the Instrument Name, Instrument
Description, etc column indicates there is no registered mapping for the metric and data is NOT
collected.

| Metric Group                     | Metric Name                                 | Attribute Keys                  | Instrument Name                                            | Instrument Description                                                                                                                            | Instrument Type             |
|----------------------------------|---------------------------------------------|---------------------------------|------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| `consumer-coordinator-metrics`   | `assigned-partitions`                       | `client-id`                     | `kafka.consumer.assigned_partitions`                       | The number of partitions currently assigned to this consumer.                                                                                     | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `commit-latency-avg`                        | `client-id`                     | `kafka.consumer.commit_latency_avg`                        | The average time taken for a commit request.                                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `commit-latency-max`                        | `client-id`                     | `kafka.consumer.commit_latency_max`                        | The max time taken for a commit request.                                                                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `commit-rate`                               | `client-id`                     | `kafka.consumer.commit_rate`                               | The number of commit calls per second.                                                                                                            | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `commit-total`                              | `client-id`                     | `kafka.consumer.commit_total`                              | The total number of commit calls.                                                                                                                 | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-coordinator-metrics`   | `failed-rebalance-rate-per-hour`            | `client-id`                     | `kafka.consumer.failed_rebalance_rate_per_hour`            | The number of failed rebalance events per hour.                                                                                                   | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `failed-rebalance-total`                    | `client-id`                     | `kafka.consumer.failed_rebalance_total`                    | The total number of failed rebalance events.                                                                                                      | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-coordinator-metrics`   | `heartbeat-rate`                            | `client-id`                     | `kafka.consumer.heartbeat_rate`                            | The number of heartbeats per second.                                                                                                              | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `heartbeat-response-time-max`               | `client-id`                     | `kafka.consumer.heartbeat_response_time_max`               | The max time taken to receive a response to a heartbeat request.                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `heartbeat-total`                           | `client-id`                     | `kafka.consumer.heartbeat_total`                           | The total number of heartbeats.                                                                                                                   | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-coordinator-metrics`   | `join-rate`                                 | `client-id`                     | `kafka.consumer.join_rate`                                 | The number of group joins per second.                                                                                                             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `join-time-avg`                             | `client-id`                     | `kafka.consumer.join_time_avg`                             | The average time taken for a group rejoin.                                                                                                        | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `join-time-max`                             | `client-id`                     | `kafka.consumer.join_time_max`                             | The max time taken for a group rejoin.                                                                                                            | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `join-total`                                | `client-id`                     | `kafka.consumer.join_total`                                | The total number of group joins.                                                                                                                  | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-coordinator-metrics`   | `last-heartbeat-seconds-ago`                | `client-id`                     | `kafka.consumer.last_heartbeat_seconds_ago`                | The number of seconds since the last coordinator heartbeat was sent.                                                                              | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `last-rebalance-seconds-ago`                | `client-id`                     | `kafka.consumer.last_rebalance_seconds_ago`                | The number of seconds since the last successful rebalance event.                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `partition-assigned-latency-avg`            | `client-id`                     | `kafka.consumer.partition_assigned_latency_avg`            | The average time taken for a partition-assigned rebalance listener callback.                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `partition-assigned-latency-max`            | `client-id`                     | `kafka.consumer.partition_assigned_latency_max`            | The max time taken for a partition-assigned rebalance listener callback.                                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `partition-lost-latency-avg`                | `client-id`                     | `kafka.consumer.partition_lost_latency_avg`                | The average time taken for a partition-lost rebalance listener callback.                                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `partition-lost-latency-max`                | `client-id`                     | `kafka.consumer.partition_lost_latency_max`                | The max time taken for a partition-lost rebalance listener callback.                                                                              | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `partition-revoked-latency-avg`             | `client-id`                     | `kafka.consumer.partition_revoked_latency_avg`             | The average time taken for a partition-revoked rebalance listener callback.                                                                       | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `partition-revoked-latency-max`             | `client-id`                     | `kafka.consumer.partition_revoked_latency_max`             | The max time taken for a partition-revoked rebalance listener callback.                                                                           | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `rebalance-latency-avg`                     | `client-id`                     | `kafka.consumer.rebalance_latency_avg`                     | The average time taken for a group to complete a successful rebalance, which may be composed of several failed re-trials until it succeeded.      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `rebalance-latency-max`                     | `client-id`                     | `kafka.consumer.rebalance_latency_max`                     | The max time taken for a group to complete a successful rebalance, which may be composed of several failed re-trials until it succeeded.          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `rebalance-latency-total`                   | `client-id`                     | `kafka.consumer.rebalance_latency_total`                   | The total number of milliseconds this consumer has spent in successful rebalances since creation.                                                 | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-coordinator-metrics`   | `rebalance-rate-per-hour`                   | `client-id`                     | `kafka.consumer.rebalance_rate_per_hour`                   | The number of successful rebalance events per hour, each event is composed of several failed re-trials until it succeeded.                        | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `rebalance-total`                           | `client-id`                     | `kafka.consumer.rebalance_total`                           | The total number of successful rebalance events, each event is composed of several failed re-trials until it succeeded.                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-coordinator-metrics`   | `sync-rate`                                 | `client-id`                     | `kafka.consumer.sync_rate`                                 | The number of group syncs per second.                                                                                                             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `sync-time-avg`                             | `client-id`                     | `kafka.consumer.sync_time_avg`                             | The average time taken for a group sync.                                                                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `sync-time-max`                             | `client-id`                     | `kafka.consumer.sync_time_max`                             | The max time taken for a group sync.                                                                                                              | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-coordinator-metrics`   | `sync-total`                                | `client-id`                     | `kafka.consumer.sync_total`                                | The total number of group syncs.                                                                                                                  | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-fetch-manager-metrics` | `bytes-consumed-rate`                       | `client-id`,`topic`             | `kafka.consumer.bytes_consumed_rate`                       | The average number of bytes consumed per second.                                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `bytes-consumed-total`                      | `client-id`,`topic`             | `kafka.consumer.bytes_consumed_total`                      | The total number of bytes consumed.                                                                                                               | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-fetch-manager-metrics` | `fetch-latency-avg`                         | `client-id`                     | `kafka.consumer.fetch_latency_avg`                         | The average time taken for a fetch request.                                                                                                       | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `fetch-latency-max`                         | `client-id`                     | `kafka.consumer.fetch_latency_max`                         | The max time taken for any fetch request.                                                                                                         | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `fetch-rate`                                | `client-id`                     | `kafka.consumer.fetch_rate`                                | The number of fetch requests per second.                                                                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `fetch-size-avg`                            | `client-id`,`topic`             | `kafka.consumer.fetch_size_avg`                            | The average number of bytes fetched per request.                                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `fetch-size-max`                            | `client-id`,`topic`             | `kafka.consumer.fetch_size_max`                            | The maximum number of bytes fetched per request.                                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `fetch-throttle-time-avg`                   | `client-id`                     | `kafka.consumer.fetch_throttle_time_avg`                   | The average throttle time in ms.                                                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `fetch-throttle-time-max`                   | `client-id`                     | `kafka.consumer.fetch_throttle_time_max`                   | The maximum throttle time in ms.                                                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `fetch-total`                               | `client-id`                     | `kafka.consumer.fetch_total`                               | The total number of fetch requests.                                                                                                               | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-fetch-manager-metrics` | `records-consumed-rate`                     | `client-id`,`topic`             | `kafka.consumer.records_consumed_rate`                     | The average number of records consumed per second.                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `records-consumed-total`                    | `client-id`,`topic`             | `kafka.consumer.records_consumed_total`                    | The total number of records consumed.                                                                                                             | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-fetch-manager-metrics` | `records-lag`                               | `client-id`,`topic`,`partition` | `kafka.consumer.records_lag`                               | The latest lag of the partition.                                                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `records-lag-avg`                           | `client-id`,`topic`,`partition` | `kafka.consumer.records_lag_avg`                           | The average lag of the partition.                                                                                                                 | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `records-lag-max`                           | `client-id`,`topic`,`partition` | `kafka.consumer.records_lag_max`                           | The maximum lag in terms of number of records for any partition in this window. NOTE: This is based on current offset and not committed offset.   | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `records-lead`                              | `client-id`,`topic`,`partition` | `kafka.consumer.records_lead`                              | The latest lead of the partition.                                                                                                                 | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `records-lead-avg`                          | `client-id`,`topic`,`partition` | `kafka.consumer.records_lead_avg`                          | The average lead of the partition.                                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `records-lead-min`                          | `client-id`,`topic`,`partition` | `kafka.consumer.records_lead_min`                          | The minimum lead in terms of number of records for any partition in this window.                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-fetch-manager-metrics` | `records-per-request-avg`                   | `client-id`,`topic`             | `kafka.consumer.records_per_request_avg`                   | The average number of records in each request.                                                                                                    | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `commit-sync-time-ns-total`                 | `client-id`                     | `kafka.consumer.commit_sync_time_ns_total`                 | The total time the consumer has spent in commitSync in nanoseconds.                                                                               | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `committed-time-ns-total`                   | `client-id`                     | `kafka.consumer.committed_time_ns_total`                   | The total time the consumer has spent in committed in nanoseconds.                                                                                | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `connection-close-rate`                     | `client-id`                     | `kafka.consumer.connection_close_rate`                     | The number of connections closed per second.                                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `connection-close-total`                    | `client-id`                     | `kafka.consumer.connection_close_total`                    | The total number of connections closed.                                                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `connection-count`                          | `client-id`                     | `kafka.consumer.connection_count`                          | The current number of active connections.                                                                                                         | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `connection-creation-rate`                  | `client-id`                     | `kafka.consumer.connection_creation_rate`                  | The number of new connections established per second.                                                                                             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `connection-creation-total`                 | `client-id`                     | `kafka.consumer.connection_creation_total`                 | The total number of new connections established.                                                                                                  | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `failed-authentication-rate`                | `client-id`                     | `kafka.consumer.failed_authentication_rate`                | The number of connections with failed authentication per second.                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `failed-authentication-total`               | `client-id`                     | `kafka.consumer.failed_authentication_total`               | The total number of connections with failed authentication.                                                                                       | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `failed-reauthentication-rate`              | `client-id`                     | `kafka.consumer.failed_reauthentication_rate`              | The number of failed re-authentication of connections per second.                                                                                 | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `failed-reauthentication-total`             | `client-id`                     | `kafka.consumer.failed_reauthentication_total`             | The total number of failed re-authentication of connections.                                                                                      | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `io-ratio`                                  | `client-id`                     | `kafka.consumer.io_ratio`                                  | *Deprecated* The fraction of time the I/O thread spent doing I/O.                                                                                 | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `io-time-ns-avg`                            | `client-id`                     | `kafka.consumer.io_time_ns_avg`                            | The average length of time for I/O per select call in nanoseconds.                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `io-time-ns-total`                          | `client-id`                     | `kafka.consumer.io_time_ns_total`                          | The total time the I/O thread spent doing I/O.                                                                                                    | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `io-wait-ratio`                             | `client-id`                     | `kafka.consumer.io_wait_ratio`                             | *Deprecated* The fraction of time the I/O thread spent waiting.                                                                                   | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `io-wait-time-ns-avg`                       | `client-id`                     | `kafka.consumer.io_wait_time_ns_avg`                       | The average length of time the I/O thread spent waiting for a socket ready for reads or writes in nanoseconds.                                    | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `io-wait-time-ns-total`                     | `client-id`                     | `kafka.consumer.io_wait_time_ns_total`                     | The total time the I/O thread spent waiting.                                                                                                      | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `io-waittime-total`                         | `client-id`                     | `kafka.consumer.io_waittime_total`                         | *Deprecated* The total time the I/O thread spent waiting.                                                                                         | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `iotime-total`                              | `client-id`                     | `kafka.consumer.iotime_total`                              | *Deprecated* The total time the I/O thread spent doing I/O.                                                                                       | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `last-poll-seconds-ago`                     | `client-id`                     | `kafka.consumer.last_poll_seconds_ago`                     | The number of seconds since the last poll() invocation.                                                                                           | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `network-io-rate`                           | `client-id`                     | `kafka.consumer.network_io_rate`                           | The number of network operations (reads or writes) on all connections per second.                                                                 | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `network-io-total`                          | `client-id`                     | `kafka.consumer.network_io_total`                          | The total number of network operations (reads or writes) on all connections.                                                                      | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `poll-idle-ratio-avg`                       | `client-id`                     | `kafka.consumer.poll_idle_ratio_avg`                       | The average fraction of time the consumer's poll() is idle as opposed to waiting for the user code to process records.                            | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `reauthentication-latency-avg`              | `client-id`                     | `kafka.consumer.reauthentication_latency_avg`              | The average latency observed due to re-authentication.                                                                                            | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `reauthentication-latency-max`              | `client-id`                     | `kafka.consumer.reauthentication_latency_max`              | The max latency observed due to re-authentication.                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `select-rate`                               | `client-id`                     | `kafka.consumer.select_rate`                               | The number of times the I/O layer checked for new I/O to perform per second.                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `select-total`                              | `client-id`                     | `kafka.consumer.select_total`                              | The total number of times the I/O layer checked for new I/O to perform.                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `successful-authentication-no-reauth-total` | `client-id`                     | `kafka.consumer.successful_authentication_no_reauth_total` | The total number of connections with successful authentication where the client does not support re-authentication.                               | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `successful-authentication-rate`            | `client-id`                     | `kafka.consumer.successful_authentication_rate`            | The number of connections with successful authentication per second.                                                                              | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `successful-authentication-total`           | `client-id`                     | `kafka.consumer.successful_authentication_total`           | The total number of connections with successful authentication.                                                                                   | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `successful-reauthentication-rate`          | `client-id`                     | `kafka.consumer.successful_reauthentication_rate`          | The number of successful re-authentication of connections per second.                                                                             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `successful-reauthentication-total`         | `client-id`                     | `kafka.consumer.successful_reauthentication_total`         | The total number of successful re-authentication of connections.                                                                                  | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-metrics`               | `time-between-poll-avg`                     | `client-id`                     | `kafka.consumer.time_between_poll_avg`                     | The average delay between invocations of poll() in milliseconds.                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-metrics`               | `time-between-poll-max`                     | `client-id`                     | `kafka.consumer.time_between_poll_max`                     | The max delay between invocations of poll() in milliseconds.                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `incoming-byte-rate`                        | `client-id`,`node-id`           | `kafka.consumer.incoming_byte_rate`                        | The number of bytes read off all sockets per second.                                                                                              | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `incoming-byte-total`                       | `client-id`,`node-id`           | `kafka.consumer.incoming_byte_total`                       | The total number of bytes read off all sockets.                                                                                                   | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-node-metrics`          | `outgoing-byte-rate`                        | `client-id`,`node-id`           | `kafka.consumer.outgoing_byte_rate`                        | The number of outgoing bytes sent to all servers per second.                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `outgoing-byte-total`                       | `client-id`,`node-id`           | `kafka.consumer.outgoing_byte_total`                       | The total number of outgoing bytes sent to all servers.                                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-node-metrics`          | `request-latency-avg`                       | `client-id`,`node-id`           | `kafka.consumer.request_latency_avg`                       | The average request latency in ms.                                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `request-latency-max`                       | `client-id`,`node-id`           | `kafka.consumer.request_latency_max`                       | The maximum request latency in ms.                                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `request-rate`                              | `client-id`,`node-id`           | `kafka.consumer.request_rate`                              | The number of requests sent per second.                                                                                                           | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `request-size-avg`                          | `client-id`,`node-id`           | `kafka.consumer.request_size_avg`                          | The average size of requests sent.                                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `request-size-max`                          | `client-id`,`node-id`           | `kafka.consumer.request_size_max`                          | The maximum size of any request sent.                                                                                                             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `request-total`                             | `client-id`,`node-id`           | `kafka.consumer.request_total`                             | The total number of requests sent.                                                                                                                | `DOUBLE_OBSERVABLE_COUNTER` |
| `consumer-node-metrics`          | `response-rate`                             | `client-id`,`node-id`           | `kafka.consumer.response_rate`                             | The number of responses received per second.                                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `consumer-node-metrics`          | `response-total`                            | `client-id`,`node-id`           | `kafka.consumer.response_total`                            | The total number of responses received.                                                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `batch-size-avg`                            | `client-id`                     | `kafka.producer.batch_size_avg`                            | The average number of bytes sent per partition per-request.                                                                                       | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `batch-size-max`                            | `client-id`                     | `kafka.producer.batch_size_max`                            | The max number of bytes sent per partition per-request.                                                                                           | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `batch-split-rate`                          | `client-id`                     | `kafka.producer.batch_split_rate`                          | The average number of batch splits per second.                                                                                                    | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `batch-split-total`                         | `client-id`                     | `kafka.producer.batch_split_total`                         | The total number of batch splits.                                                                                                                 | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `buffer-available-bytes`                    | `client-id`                     | `kafka.producer.buffer_available_bytes`                    | The total amount of buffer memory that is not being used (either unallocated or in the free list).                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `buffer-exhausted-rate`                     | `client-id`                     | `kafka.producer.buffer_exhausted_rate`                     | The average per-second number of record sends that are dropped due to buffer exhaustion.                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `buffer-exhausted-total`                    | `client-id`                     | `kafka.producer.buffer_exhausted_total`                    | The total number of record sends that are dropped due to buffer exhaustion.                                                                       | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `buffer-total-bytes`                        | `client-id`                     | `kafka.producer.buffer_total_bytes`                        | The maximum amount of buffer memory the client can use (whether or not it is currently used).                                                     | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `bufferpool-wait-ratio`                     | `client-id`                     | `kafka.producer.bufferpool_wait_ratio`                     | The fraction of time an appender waits for space allocation.                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `bufferpool-wait-time-ns-total`             | `client-id`                     | `kafka.producer.bufferpool_wait_time_ns_total`             | The total time in nanoseconds an appender waits for space allocation.                                                                             | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `bufferpool-wait-time-total`                | `client-id`                     | `kafka.producer.bufferpool_wait_time_total`                | *Deprecated* The total time an appender waits for space allocation.                                                                               | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `compression-rate-avg`                      | `client-id`                     | `kafka.producer.compression_rate_avg`                      | The average compression rate of record batches, defined as the average ratio of the compressed batch size over the uncompressed size.             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `connection-close-rate`                     | `client-id`                     | `kafka.producer.connection_close_rate`                     | The number of connections closed per second.                                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `connection-close-total`                    | `client-id`                     | `kafka.producer.connection_close_total`                    | The total number of connections closed.                                                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `connection-count`                          | `client-id`                     | `kafka.producer.connection_count`                          | The current number of active connections.                                                                                                         | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `connection-creation-rate`                  | `client-id`                     | `kafka.producer.connection_creation_rate`                  | The number of new connections established per second.                                                                                             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `connection-creation-total`                 | `client-id`                     | `kafka.producer.connection_creation_total`                 | The total number of new connections established.                                                                                                  | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `failed-authentication-rate`                | `client-id`                     | `kafka.producer.failed_authentication_rate`                | The number of connections with failed authentication per second.                                                                                  | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `failed-authentication-total`               | `client-id`                     | `kafka.producer.failed_authentication_total`               | The total number of connections with failed authentication.                                                                                       | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `failed-reauthentication-rate`              | `client-id`                     | `kafka.producer.failed_reauthentication_rate`              | The number of failed re-authentication of connections per second.                                                                                 | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `failed-reauthentication-total`             | `client-id`                     | `kafka.producer.failed_reauthentication_total`             | The total number of failed re-authentication of connections.                                                                                      | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `flush-time-ns-total`                       | `client-id`                     | `kafka.producer.flush_time_ns_total`                       | Total time producer has spent in flush in nanoseconds.                                                                                            | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `io-ratio`                                  | `client-id`                     | `kafka.producer.io_ratio`                                  | *Deprecated* The fraction of time the I/O thread spent doing I/O.                                                                                 | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `io-time-ns-avg`                            | `client-id`                     | `kafka.producer.io_time_ns_avg`                            | The average length of time for I/O per select call in nanoseconds.                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `io-time-ns-total`                          | `client-id`                     | `kafka.producer.io_time_ns_total`                          | The total time the I/O thread spent doing I/O.                                                                                                    | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `io-wait-ratio`                             | `client-id`                     | `kafka.producer.io_wait_ratio`                             | *Deprecated* The fraction of time the I/O thread spent waiting.                                                                                   | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `io-wait-time-ns-avg`                       | `client-id`                     | `kafka.producer.io_wait_time_ns_avg`                       | The average length of time the I/O thread spent waiting for a socket ready for reads or writes in nanoseconds.                                    | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `io-wait-time-ns-total`                     | `client-id`                     | `kafka.producer.io_wait_time_ns_total`                     | The total time the I/O thread spent waiting.                                                                                                      | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `io-waittime-total`                         | `client-id`                     | `kafka.producer.io_waittime_total`                         | *Deprecated* The total time the I/O thread spent waiting.                                                                                         | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `iotime-total`                              | `client-id`                     | `kafka.producer.iotime_total`                              | *Deprecated* The total time the I/O thread spent doing I/O.                                                                                       | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `metadata-age`                              | `client-id`                     | `kafka.producer.metadata_age`                              | The age in seconds of the current producer metadata being used.                                                                                   | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `metadata-wait-time-ns-total`               | `client-id`                     | `kafka.producer.metadata_wait_time_ns_total`               | Total time producer has spent waiting on topic metadata in nanoseconds.                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `network-io-rate`                           | `client-id`                     | `kafka.producer.network_io_rate`                           | The number of network operations (reads or writes) on all connections per second.                                                                 | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `network-io-total`                          | `client-id`                     | `kafka.producer.network_io_total`                          | The total number of network operations (reads or writes) on all connections.                                                                      | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `produce-throttle-time-avg`                 | `client-id`                     | `kafka.producer.produce_throttle_time_avg`                 | The average time in ms a request was throttled by a broker.                                                                                       | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `produce-throttle-time-max`                 | `client-id`                     | `kafka.producer.produce_throttle_time_max`                 | The maximum time in ms a request was throttled by a broker.                                                                                       | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `reauthentication-latency-avg`              | `client-id`                     | `kafka.producer.reauthentication_latency_avg`              | The average latency observed due to re-authentication.                                                                                            | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `reauthentication-latency-max`              | `client-id`                     | `kafka.producer.reauthentication_latency_max`              | The max latency observed due to re-authentication.                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `record-queue-time-avg`                     | `client-id`                     | `kafka.producer.record_queue_time_avg`                     | The average time in ms record batches spent in the send buffer.                                                                                   | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `record-queue-time-max`                     | `client-id`                     | `kafka.producer.record_queue_time_max`                     | The maximum time in ms record batches spent in the send buffer.                                                                                   | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `record-size-avg`                           | `client-id`                     | `kafka.producer.record_size_avg`                           | The average record size.                                                                                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `record-size-max`                           | `client-id`                     | `kafka.producer.record_size_max`                           | The maximum record size.                                                                                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `records-per-request-avg`                   | `client-id`                     | `kafka.producer.records_per_request_avg`                   | The average number of records per request.                                                                                                        | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `requests-in-flight`                        | `client-id`                     | `kafka.producer.requests_in_flight`                        | The current number of in-flight requests awaiting a response.                                                                                     | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `select-rate`                               | `client-id`                     | `kafka.producer.select_rate`                               | The number of times the I/O layer checked for new I/O to perform per second.                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `select-total`                              | `client-id`                     | `kafka.producer.select_total`                              | The total number of times the I/O layer checked for new I/O to perform.                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `successful-authentication-no-reauth-total` | `client-id`                     | `kafka.producer.successful_authentication_no_reauth_total` | The total number of connections with successful authentication where the client does not support re-authentication.                               | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `successful-authentication-rate`            | `client-id`                     | `kafka.producer.successful_authentication_rate`            | The number of connections with successful authentication per second.                                                                              | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `successful-authentication-total`           | `client-id`                     | `kafka.producer.successful_authentication_total`           | The total number of connections with successful authentication.                                                                                   | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `successful-reauthentication-rate`          | `client-id`                     | `kafka.producer.successful_reauthentication_rate`          | The number of successful re-authentication of connections per second.                                                                             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-metrics`               | `successful-reauthentication-total`         | `client-id`                     | `kafka.producer.successful_reauthentication_total`         | The total number of successful re-authentication of connections.                                                                                  | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `txn-abort-time-ns-total`                   | `client-id`                     | `kafka.producer.txn_abort_time_ns_total`                   | Total time producer has spent in abortTransaction in nanoseconds.                                                                                 | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `txn-begin-time-ns-total`                   | `client-id`                     | `kafka.producer.txn_begin_time_ns_total`                   | Total time producer has spent in beginTransaction in nanoseconds.                                                                                 | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `txn-commit-time-ns-total`                  | `client-id`                     | `kafka.producer.txn_commit_time_ns_total`                  | Total time producer has spent in commitTransaction in nanoseconds.                                                                                | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `txn-init-time-ns-total`                    | `client-id`                     | `kafka.producer.txn_init_time_ns_total`                    | Total time producer has spent in initTransactions in nanoseconds.                                                                                 | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `txn-send-offsets-time-ns-total`            | `client-id`                     | `kafka.producer.txn_send_offsets_time_ns_total`            | Total time producer has spent in sendOffsetsToTransaction in nanoseconds.                                                                         | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-metrics`               | `waiting-threads`                           | `client-id`                     | `kafka.producer.waiting_threads`                           | The number of user threads blocked waiting for buffer memory to enqueue their records.                                                            | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `incoming-byte-rate`                        | `client-id`,`node-id`           | `kafka.producer.incoming_byte_rate`                        | The number of bytes read off all sockets per second.                                                                                              | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `incoming-byte-total`                       | `client-id`,`node-id`           | `kafka.producer.incoming_byte_total`                       | The total number of bytes read off all sockets.                                                                                                   | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-node-metrics`          | `outgoing-byte-rate`                        | `client-id`,`node-id`           | `kafka.producer.outgoing_byte_rate`                        | The number of outgoing bytes sent to all servers per second.                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `outgoing-byte-total`                       | `client-id`,`node-id`           | `kafka.producer.outgoing_byte_total`                       | The total number of outgoing bytes sent to all servers.                                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-node-metrics`          | `request-latency-avg`                       | `client-id`,`node-id`           | `kafka.producer.request_latency_avg`                       | The average request latency in ms.                                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `request-latency-max`                       | `client-id`,`node-id`           | `kafka.producer.request_latency_max`                       | The maximum request latency in ms.                                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `request-rate`                              | `client-id`,`node-id`           | `kafka.producer.request_rate`                              | The number of requests sent per second.                                                                                                           | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `request-size-avg`                          | `client-id`,`node-id`           | `kafka.producer.request_size_avg`                          | The average size of requests sent.                                                                                                                | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `request-size-max`                          | `client-id`,`node-id`           | `kafka.producer.request_size_max`                          | The maximum size of any request sent.                                                                                                             | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `request-total`                             | `client-id`,`node-id`           | `kafka.producer.request_total`                             | The total number of requests sent.                                                                                                                | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-node-metrics`          | `response-rate`                             | `client-id`,`node-id`           | `kafka.producer.response_rate`                             | The number of responses received per second.                                                                                                      | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-node-metrics`          | `response-total`                            | `client-id`,`node-id`           | `kafka.producer.response_total`                            | The total number of responses received.                                                                                                           | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-topic-metrics`         | `byte-rate`                                 | `client-id`,`topic`             | `kafka.producer.byte_rate`                                 | The average number of bytes sent per second for a topic.                                                                                          | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-topic-metrics`         | `byte-total`                                | `client-id`,`topic`             | `kafka.producer.byte_total`                                | The total number of bytes sent for a topic.                                                                                                       | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-topic-metrics`         | `compression-rate`                          | `client-id`,`topic`             | `kafka.producer.compression_rate`                          | The average compression rate of record batches for a topic, defined as the average ratio of the compressed batch size over the uncompressed size. | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-topic-metrics`         | `record-error-rate`                         | `client-id`,`topic`             | `kafka.producer.record_error_rate`                         | The average per-second number of record sends that resulted in errors.                                                                            | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-topic-metrics`         | `record-error-total`                        | `client-id`,`topic`             | `kafka.producer.record_error_total`                        | The total number of record sends that resulted in errors.                                                                                         | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-topic-metrics`         | `record-retry-rate`                         | `client-id`,`topic`             | `kafka.producer.record_retry_rate`                         | The average per-second number of retried record sends.                                                                                            | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-topic-metrics`         | `record-retry-total`                        | `client-id`,`topic`             | `kafka.producer.record_retry_total`                        | The total number of retried record sends.                                                                                                         | `DOUBLE_OBSERVABLE_COUNTER` |
| `producer-topic-metrics`         | `record-send-rate`                          | `client-id`,`topic`             | `kafka.producer.record_send_rate`                          | The average number of records sent per second.                                                                                                    | `DOUBLE_OBSERVABLE_GAUGE`   |
| `producer-topic-metrics`         | `record-send-total`                         | `client-id`,`topic`             | `kafka.producer.record_send_total`                         | The total number of records sent.                                                                                                                 | `DOUBLE_OBSERVABLE_COUNTER` |
