Skip to content

Commit c3e5245

Browse files
authored
Remove unused kafka metrics from doc (#10371)
1 parent bb8e301 commit c3e5245

File tree

2 files changed

+200
-205
lines changed

2 files changed

+200
-205
lines changed

instrumentation/kafka/kafka-clients/kafka-clients-0.11/testing/src/main/java/io/opentelemetry/instrumentation/kafka/internal/AbstractOpenTelemetryMetricsReporterTest.java

+24-1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ private static void printMappingTable() {
396396
.equals(kafkaMetricId))
397397
.findFirst()
398398
.map(RegisteredObservable::getInstrumentDescriptor);
399+
if (!descriptor.isPresent()) {
400+
continue;
401+
}
399402
// Append table row
400403
sb.append(
401404
String.format(
@@ -406,13 +409,27 @@ private static void printMappingTable() {
406409
.map(key -> "`" + key + "`")
407410
.collect(joining(",")),
408411
descriptor.map(i -> "`" + i.getName() + "`").orElse(""),
409-
descriptor.map(InstrumentDescriptor::getDescription).orElse(""),
412+
descriptor.map(i -> toDescription(i)).orElse(""),
410413
descriptor.map(i -> "`" + i.getInstrumentType() + "`").orElse("")));
411414
}
412415
}
413416
logger.info("Mapping table" + System.lineSeparator() + sb);
414417
}
415418

419+
private static String toDescription(InstrumentDescriptor instrumentDescriptor) {
420+
String description = instrumentDescriptor.getDescription();
421+
if (!description.isEmpty() && !description.endsWith(".")) {
422+
return description + ".";
423+
} else if (description.isEmpty()
424+
&& "kafka.consumer.request_latency_avg".equals(instrumentDescriptor.getName())) {
425+
return "The average request latency in ms.";
426+
} else if (description.isEmpty()
427+
&& "kafka.consumer.request_latency_max".equals(instrumentDescriptor.getName())) {
428+
return "The maximum request latency in ms.";
429+
}
430+
return description;
431+
}
432+
416433
/**
417434
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
418435
* any time.
@@ -428,6 +445,12 @@ public void init(List<KafkaMetric> list) {
428445

429446
@Override
430447
public void metricChange(KafkaMetric kafkaMetric) {
448+
try {
449+
kafkaMetric.measurable();
450+
} catch (IllegalStateException exception) {
451+
// ignore non-measurable metrics, we don't report them
452+
return;
453+
}
431454
seenMetrics.add(KafkaMetricId.create(kafkaMetric.metricName()));
432455
}
433456

0 commit comments

Comments
 (0)