use of io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk in project opentelemetry-plugin by jenkinsci.
the class GlobalOpenTelemetrySdk method configure.
private static void configure(SdkConfigurationParameters newSdkConfigurationParameters, boolean registerShutDownHook) {
Lock readLock = readWriteLock.readLock();
readLock.lock();
try {
// VERIFY IF CONFIGURATION HAS CHANGED
if (Objects.equals(newSdkConfigurationParameters, openTelemetrySdkState.getSdkConfigurationParameters())) {
logger.log(Level.FINEST, () -> "OpenTelemetry SDK configuration has NOT changed, don't reinitialize SDK");
return;
}
} finally {
readLock.unlock();
}
Lock writeLock = readWriteLock.writeLock();
writeLock.lock();
try {
if (Objects.equals(newSdkConfigurationParameters, openTelemetrySdkState.getSdkConfigurationParameters())) {
logger.log(Level.FINEST, () -> "OpenTelemetry SDK configuration has NOT changed");
return;
}
logger.log(Level.FINEST, () -> "Initialize/reinitialize OpenTelemetry SDK...");
shutdown();
final AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk = AutoConfiguredOpenTelemetrySdk.builder().addPropertiesSupplier(() -> newSdkConfigurationParameters.configurationProperties).addResourceCustomizer((resource, configProperties) -> {
AttributesBuilder attributesBuilder = Attributes.builder();
newSdkConfigurationParameters.resourceAttributes.forEach(attributesBuilder::put);
return Resource.builder().putAll(resource).putAll(attributesBuilder.build()).build();
}).registerShutdownHook(registerShutDownHook).build();
openTelemetrySdkState = new OpenTelemetrySdkStateImpl(autoConfiguredOpenTelemetrySdk, newSdkConfigurationParameters);
logger.log(Level.INFO, () -> "OpenTelemetry SDK initialized: " + OtelUtils.prettyPrintOtelSdkConfig(autoConfiguredOpenTelemetrySdk));
configurationCounter.incrementAndGet();
} finally {
writeLock.unlock();
}
}
use of io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk in project incubator-shenyu by apache.
the class OpenTelemetryAgentPluginBootService method start.
@Override
public void start(final AgentPluginConfig agentPluginConfig) {
agentPluginConfig.getProps().forEach((key, value) -> System.setProperty(String.valueOf(key), String.valueOf(value)));
AutoConfiguredOpenTelemetrySdk sdk = AutoConfiguredOpenTelemetrySdk.initialize();
sdkTracerProvider = sdk.getOpenTelemetrySdk().getSdkTracerProvider();
}
Aggregations