@ Get ( "/metrics" ) @ ProducesJson public ObjectNode fetchMetricsFromMicrometer ( ) { ObjectNode metricsJson = factory . objectNode ( ) ; // Get the Zipkin Custom meters for constructing the Metrics endpoint for ( Meter meter : meterRegistry . getMeters ( ) ) { String name = meter . getId ( ) . getName ( ) ; if ( ! name . startsWith ( "zipkin_collector" ) ) continue ; String transport = meter . getId ( ) . getTag ( "transport" ) ; if ( transport == null ) continue ; switch ( meter . getId ( ) . getType ( ) ) { case COUNTER : metricsJson . put ( "counter." + name + "." + transport , ( ( Counter ) meter ) . count ( ) ) ; continue ; case GAUGE : metricsJson . put ( "gauge." + name + "." + transport , ( ( Gauge ) meter ) . value ( ) ) ; } } return metricsJson ; }
Extracts Zipkin metrics to provide backward compatibility