in universal-profiling-integration/src/main/java/co/elastic/otel/UniversalProfilingProcessorAutoConfig.java [53:100]
public void registerSpanProcessors(
ConfigProperties properties, ChainingSpanProcessorRegisterer registerer) {
String enabledDefault = EnabledOptions.AUTO.toString();
String unsupportedReason = JvmtiAccess.getSystemUnsupportedReason();
if (unsupportedReason != null) {
logger.log(
Level.FINE,
"Default value for {0} is false, because the system is unsupported: {1}",
new Object[] {ENABLED_OPTION, unsupportedReason});
enabledDefault = EnabledOptions.FALSE.toString();
}
String enabledString = properties.getString(ENABLED_OPTION, enabledDefault).toUpperCase();
EnabledOptions enabled = EnabledOptions.valueOf(enabledString);
if (enabled == EnabledOptions.FALSE) {
return;
}
Resource resource = ResourceConfiguration.createEnvironmentResource(properties);
String serviceName = resource.getAttribute(ServiceAttributes.SERVICE_NAME);
if (serviceName == null || serviceName.isEmpty()) {
logger.warning(
"Cannot start universal profiling integration because no service name was configured");
return;
}
PropertiesApplier props = new PropertiesApplier(properties);
registerer.register(
next -> {
try {
UniversalProfilingProcessorBuilder builder =
UniversalProfilingProcessor.builder(next, resource);
builder.delayActivationAfterProfilerRegistration(enabled == EnabledOptions.AUTO);
props.applyInt(BUFFER_SIZE_OPTION, builder::bufferSize);
props.applyString(SOCKET_DIR_OPTION, builder::socketDir);
props.applyBool(VIRTUAL_THREAD_SUPPORT_OPTION, builder::virtualThreadSupportEnabled);
return builder.build();
} catch (Exception e) {
logger.log(
Level.SEVERE,
"Failed to initialize universal profiling integration, the feature won't work",
e);
return next;
}
});
}