use of com.microsoft.applicationinsights.agent.internal.legacyheaders.AiLegacyHeaderSpanProcessor in project ApplicationInsights-Java by microsoft.
the class OpenTelemetryConfigurer method configure.
@Override
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "this method is only called once during initialization")
public void configure(SdkTracerProviderBuilder tracerProvider, ConfigProperties config) {
TelemetryClient telemetryClient = TelemetryClient.getActive();
if (telemetryClient == null) {
// agent failed during startup
return;
}
Configuration configuration = MainEntryPoint.getConfiguration();
tracerProvider.setSampler(DelegatingSampler.getInstance());
if (configuration.connectionString != null) {
if (!configuration.preview.disablePropagation) {
DelegatingPropagator.getInstance().setUpStandardDelegate(configuration.preview.legacyRequestIdPropagation.enabled);
}
DelegatingSampler.getInstance().setDelegate(Samplers.getSampler(configuration.sampling.percentage, configuration));
} else {
// in Azure Functions, we configure later on, once we know user has opted in to tracing
// (note: the default for DelegatingPropagator is to not propagate anything
// and the default for DelegatingSampler is to not sample anything)
}
// operation name span processor is only applied on span start, so doesn't need to be chained
// with the batch span processor
tracerProvider.addSpanProcessor(new AiOperationNameSpanProcessor());
// chained with the batch span processor
if (!configuration.preview.inheritedAttributes.isEmpty()) {
tracerProvider.addSpanProcessor(new InheritedAttributesSpanProcessor(configuration.preview.inheritedAttributes));
}
// propagator)
if (configuration.preview.legacyRequestIdPropagation.enabled) {
tracerProvider.addSpanProcessor(new AiLegacyHeaderSpanProcessor());
}
// to be chained with the batch span processor
if (!configuration.preview.instrumentationKeyOverrides.isEmpty()) {
tracerProvider.addSpanProcessor(new InheritedInstrumentationKeySpanProcessor(configuration.preview.instrumentationKeyOverrides));
}
String tracesExporter = config.getString("otel.traces.exporter");
if ("none".equals(tracesExporter)) {
batchSpanProcessor = createExporter(configuration);
tracerProvider.addSpanProcessor(batchSpanProcessor);
}
}
Aggregations