Fix kafka metrics latest dep test failure
MODIFY
instrumentation/kafka/kafka-clients/kafka-clients-common/library/src/main/java/io/opentelemetry/instrumentation/kafka/internal/KafkaMetricRegistry.java
instrumentation/kafka/kafka-clients/kafka-clients-common/library/src/main/java/io/opentelemetry/instrumentation/kafka/internal/KafkaMetricRegistry.java
@@ -121,7 +121,7 @@ final class KafkaMetricRegistry {
InstrumentDescriptor instrumentDescriptor,
KafkaMetric kafkaMetric) {
Consumer<ObservableDoubleMeasurement> callback =
- observableMeasurement -> observableMeasurement.record(kafkaMetric.value(), attributes);
+ observableMeasurement -> observableMeasurement.record(value(kafkaMetric), attributes);
switch (instrumentDescriptor.getInstrumentType()) {
case INSTRUMENT_TYPE_DOUBLE_OBSERVABLE_GAUGE:
return meter
@@ -141,5 +141,9 @@ final class KafkaMetricRegistry {
throw new IllegalStateException("Unrecognized instrument type. This is a bug.");
}
+ private static double value(KafkaMetric kafkaMetric) {
+ return kafkaMetric.measurable().measure(kafkaMetric.config(), System.currentTimeMillis());
+ }
+
private KafkaMetricRegistry() {}
}

MODIFY
instrumentation/kafka/kafka-clients/kafka-clients-common/library/src/main/java/io/opentelemetry/instrumentation/kafka/internal/OpenTelemetryMetricsReporter.java
instrumentation/kafka/kafka-clients/kafka-clients-common/library/src/main/java/io/opentelemetry/instrumentation/kafka/internal/OpenTelemetryMetricsReporter.java
@@ -24,7 +24,7 @@ import org.apache.kafka.common.metrics.MetricsReporter;
*
* <p>To configure, use:
*
- * <pre><{@code
+ * <pre>{@code
* // KafkaTelemetry.KafkaTelemetry.create(OpenTelemetry).metricConfigProperties()
* }</pre>
*

Fix kafka metrics latest dep test failure (#6282)