|
|
|
@ -21,6 +21,7 @@ import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import io.micrometer.core.instrument.observation.MeterObservationHandler;
|
|
|
|
|
import io.micrometer.observation.Observation.Context;
|
|
|
|
|
import io.micrometer.observation.ObservationHandler;
|
|
|
|
|
import io.micrometer.observation.ObservationHandler.FirstMatchingCompositeObservationHandler;
|
|
|
|
|
import io.micrometer.observation.ObservationRegistry.ObservationConfig;
|
|
|
|
@ -41,10 +42,10 @@ import io.micrometer.tracing.handler.TracingObservationHandler;
|
|
|
|
|
class TracingObservationHandlerGrouping implements ObservationHandlerGrouping {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void apply(Collection<ObservationHandler<?>> handlers, ObservationConfig config) {
|
|
|
|
|
List<ObservationHandler<?>> meterObservationHandlers = new ArrayList<>();
|
|
|
|
|
List<ObservationHandler<?>> tracingObservationHandlers = new ArrayList<>();
|
|
|
|
|
for (ObservationHandler<?> handler : handlers) {
|
|
|
|
|
public void apply(Collection<ObservationHandler<Context>> handlers, ObservationConfig config) {
|
|
|
|
|
List<ObservationHandler<Context>> meterObservationHandlers = new ArrayList<>();
|
|
|
|
|
List<ObservationHandler<Context>> tracingObservationHandlers = new ArrayList<>();
|
|
|
|
|
for (ObservationHandler<Context> handler : handlers) {
|
|
|
|
|
if (handler instanceof MeterObservationHandler<?>) {
|
|
|
|
|
meterObservationHandlers.add(handler);
|
|
|
|
|
}
|
|
|
|
@ -57,19 +58,11 @@ class TracingObservationHandlerGrouping implements ObservationHandlerGrouping {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!meterObservationHandlers.isEmpty()) {
|
|
|
|
|
config.observationHandler(
|
|
|
|
|
new FirstMatchingCompositeObservationHandler(castToRawType(meterObservationHandlers)));
|
|
|
|
|
config.observationHandler(new FirstMatchingCompositeObservationHandler(meterObservationHandlers));
|
|
|
|
|
}
|
|
|
|
|
if (!tracingObservationHandlers.isEmpty()) {
|
|
|
|
|
config.observationHandler(
|
|
|
|
|
new FirstMatchingCompositeObservationHandler(castToRawType(tracingObservationHandlers)));
|
|
|
|
|
config.observationHandler(new FirstMatchingCompositeObservationHandler(tracingObservationHandlers));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
|
|
private List<ObservationHandler> castToRawType(List<ObservationHandler<?>> handlers) {
|
|
|
|
|
// See https://github.com/micrometer-metrics/micrometer/issues/3064
|
|
|
|
|
return (List) handlers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|