@@ -396,6 +396,9 @@ private static void printMappingTable() {
396
396
.equals (kafkaMetricId ))
397
397
.findFirst ()
398
398
.map (RegisteredObservable ::getInstrumentDescriptor );
399
+ if (!descriptor .isPresent ()) {
400
+ continue ;
401
+ }
399
402
// Append table row
400
403
sb .append (
401
404
String .format (
@@ -406,13 +409,27 @@ private static void printMappingTable() {
406
409
.map (key -> "`" + key + "`" )
407
410
.collect (joining ("," )),
408
411
descriptor .map (i -> "`" + i .getName () + "`" ).orElse ("" ),
409
- descriptor .map (InstrumentDescriptor :: getDescription ).orElse ("" ),
412
+ descriptor .map (i -> toDescription ( i ) ).orElse ("" ),
410
413
descriptor .map (i -> "`" + i .getInstrumentType () + "`" ).orElse ("" )));
411
414
}
412
415
}
413
416
logger .info ("Mapping table" + System .lineSeparator () + sb );
414
417
}
415
418
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
+
416
433
/**
417
434
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
418
435
* any time.
@@ -428,6 +445,12 @@ public void init(List<KafkaMetric> list) {
428
445
429
446
@ Override
430
447
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
+ }
431
454
seenMetrics .add (KafkaMetricId .create (kafkaMetric .metricName ()));
432
455
}
433
456
0 commit comments