use of io.micronaut.scheduling.instrument.InvocationInstrumenter in project micronaut-core by micronaut-projects.
the class ReactorInstrumentation method init.
/**
* Initialize instrumentation for reactor with the tracer and factory.
*
* @param instrumenterFactory The instrumenter factory
*/
@SuppressWarnings("unchecked")
@PostConstruct
void init(ReactorInstrumenterFactory instrumenterFactory) {
if (instrumenterFactory.hasInstrumenters()) {
Schedulers.onScheduleHook(Environment.MICRONAUT, runnable -> {
InvocationInstrumenter instrumenter = instrumenterFactory.create();
if (instrumenter != null) {
return () -> {
try (Instrumentation ignored = instrumenter.newInstrumentation()) {
runnable.run();
}
};
}
return runnable;
});
Hooks.onEachOperator(Environment.MICRONAUT, Operators.lift((scannable, coreSubscriber) -> {
if (coreSubscriber instanceof ReactorSubscriber) {
return coreSubscriber;
}
InvocationInstrumenter instrumenter = instrumenterFactory.create();
if (instrumenter != null) {
return new ReactorSubscriber<>(instrumenter, coreSubscriber);
}
return coreSubscriber;
}));
}
}
Aggregations