in components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsAutoConfiguration.java [51:120]
private void configureMicrometer(CamelContext camelContext, CamelMetricsConfiguration configuration,
MeterRegistry meterRegistry) {
if (configuration.isEnableRoutePolicy()) {
MicrometerRoutePolicyFactory factory = new MicrometerRoutePolicyFactory();
factory.setCamelContext(camelContext);
factory.setMeterRegistry(meterRegistry);
if ("legacy".equalsIgnoreCase(configuration.getNamingStrategy())) {
factory.setNamingStrategy(MicrometerRoutePolicyNamingStrategy.LEGACY);
}
if ("all".equalsIgnoreCase(configuration.getRoutePolicyLevel())) {
factory.getPolicyConfiguration().setContextEnabled(true);
factory.getPolicyConfiguration().setRouteEnabled(true);
} else if ("context".equalsIgnoreCase(configuration.getRoutePolicyLevel())) {
factory.getPolicyConfiguration().setContextEnabled(true);
factory.getPolicyConfiguration().setRouteEnabled(false);
} else {
factory.getPolicyConfiguration().setContextEnabled(false);
factory.getPolicyConfiguration().setRouteEnabled(true);
}
factory.getPolicyConfiguration().setExcludePattern(configuration.getRoutePolicyExcludePattern());
camelContext.addRoutePolicyFactory(factory);
}
ManagementStrategy managementStrategy = camelContext.getManagementStrategy();
if (configuration.isEnableExchangeEventNotifier()) {
MicrometerExchangeEventNotifier notifier = new MicrometerExchangeEventNotifier();
notifier.setCamelContext(camelContext);
notifier.setMeterRegistry(meterRegistry);
if ("legacy".equalsIgnoreCase(configuration.getNamingStrategy())) {
notifier.setNamingStrategy(new MicrometerExchangeEventNotifierNamingStrategyLegacy(
configuration.isBaseEndpointUriExchangeEventNotifier()
));
} else {
notifier.setNamingStrategy(new MicrometerExchangeEventNotifierNamingStrategyDefault(
configuration.isBaseEndpointUriExchangeEventNotifier()
));
}
managementStrategy.addEventNotifier(notifier);
}
if (configuration.isEnableRouteEventNotifier()) {
MicrometerRouteEventNotifier notifier = new MicrometerRouteEventNotifier();
notifier.setCamelContext(camelContext);
notifier.setMeterRegistry(meterRegistry);
if ("legacy".equalsIgnoreCase(configuration.getNamingStrategy())) {
notifier.setNamingStrategy(MicrometerRouteEventNotifierNamingStrategy.LEGACY);
}
managementStrategy.addEventNotifier(notifier);
}
if (configuration.isEnableMessageHistory()) {
if (!camelContext.isMessageHistory()) {
camelContext.setMessageHistory(true);
}
MicrometerMessageHistoryFactory factory = new MicrometerMessageHistoryFactory();
factory.setCamelContext(camelContext);
factory.setMeterRegistry(meterRegistry);
if ("legacy".equalsIgnoreCase(configuration.getNamingStrategy())) {
factory.setNamingStrategy(MicrometerMessageHistoryNamingStrategy.LEGACY);
}
camelContext.setMessageHistoryFactory(factory);
}
if (configuration.isEnableInstrumentedThreadPoolFactory()) {
InstrumentedThreadPoolFactory instrumentedThreadPoolFactory = new InstrumentedThreadPoolFactory(
meterRegistry,
camelContext.getExecutorServiceManager().getThreadPoolFactory());
camelContext.getExecutorServiceManager().setThreadPoolFactory(instrumentedThreadPoolFactory);
}
}