Class AutoConfiguredOpenTelemetrySdkBuilder
- All Implemented Interfaces:
AutoConfigurationCustomizer
- Since:
- 1.28.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ComponentLoader
private ConfigProperties
private Function
<ConfigProperties, ConfigProperties> private boolean
private static final Logger
private BiFunction
<? super LogRecordExporter, ConfigProperties, ? extends LogRecordExporter> private BiFunction
<? super LogRecordProcessor, ConfigProperties, ? extends LogRecordProcessor> private BiFunction
<? super MetricExporter, ConfigProperties, ? extends MetricExporter> private BiFunction
<? super MetricReader, ConfigProperties, ? extends MetricReader> private BiFunction
<? super TextMapPropagator, ConfigProperties, ? extends TextMapPropagator> private boolean
private BiFunction
<? super Resource, ConfigProperties, ? extends Resource> private BiFunction
<? super Sampler, ConfigProperties, ? extends Sampler> private boolean
private BiFunction
<? super SpanExporter, ConfigProperties, ? extends SpanExporter> private BiFunction
<? super SpanProcessor, ConfigProperties, ? extends SpanProcessor> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLoggerProviderCustomizer
(BiFunction<SdkLoggerProviderBuilder, ConfigProperties, SdkLoggerProviderBuilder> loggerProviderCustomizer) Adds aBiFunction
to invoke the with theSdkLoggerProviderBuilder
to allow customization.addLogRecordExporterCustomizer
(BiFunction<? super LogRecordExporter, ConfigProperties, ? extends LogRecordExporter> logRecordExporterCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredLogRecordExporter
to allow customization.addLogRecordProcessorCustomizer
(BiFunction<? super LogRecordProcessor, ConfigProperties, ? extends LogRecordProcessor> logRecordProcessorCustomizer) Adds aBiFunction
to invoke for all autoconfiguredLogRecordProcessor
s.addMeterProviderCustomizer
(BiFunction<SdkMeterProviderBuilder, ConfigProperties, SdkMeterProviderBuilder> meterProviderCustomizer) Adds aBiFunction
to invoke the with theSdkMeterProviderBuilder
to allow customization.addMetricExporterCustomizer
(BiFunction<? super MetricExporter, ConfigProperties, ? extends MetricExporter> metricExporterCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredSpanExporter
to allow customization.addMetricReaderCustomizer
(BiFunction<? super MetricReader, ConfigProperties, ? extends MetricReader> readerCustomizer) Adds aBiFunction
to invoke with the autoconfiguredMetricReader
to allow customization.addPropagatorCustomizer
(BiFunction<? super TextMapPropagator, ConfigProperties, ? extends TextMapPropagator> propagatorCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredTextMapPropagator
to allow customization.addPropertiesCustomizer
(Function<ConfigProperties, Map<String, String>> propertiesCustomizer) Adds aFunction
to invoke the with theConfigProperties
to allow customization.addPropertiesSupplier
(Supplier<Map<String, String>> propertiesSupplier) Adds aSupplier
of a map of property names and values to use as defaults for theConfigProperties
used during auto-configuration.addResourceCustomizer
(BiFunction<? super Resource, ConfigProperties, ? extends Resource> resourceCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredResource
to allow customization.addSamplerCustomizer
(BiFunction<? super Sampler, ConfigProperties, ? extends Sampler> samplerCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredSampler
to allow customization.addSpanExporterCustomizer
(BiFunction<? super SpanExporter, ConfigProperties, ? extends SpanExporter> spanExporterCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredSpanExporter
to allow customization.addSpanProcessorCustomizer
(BiFunction<? super SpanProcessor, ConfigProperties, ? extends SpanProcessor> spanProcessorCustomizer) Adds aBiFunction
to invoke for all autoconfiguredSpanProcessor
.addTracerProviderCustomizer
(BiFunction<SdkTracerProviderBuilder, ConfigProperties, SdkTracerProviderBuilder> tracerProviderCustomizer) Adds aBiFunction
to invoke the with theSdkTracerProviderBuilder
to allow customization.build()
Returns a newAutoConfiguredOpenTelemetrySdk
holding components auto-configured using the settings of thisAutoConfiguredOpenTelemetrySdkBuilder
.(package private) void
callAutoConfigureListeners
(SpiHelper spiHelper, OpenTelemetrySdk openTelemetrySdk) private ConfigProperties
Disable the registration of a shutdown hook to shut down the SDK when appropriate.private ConfigProperties
private static AutoConfiguredOpenTelemetrySdk
maybeConfigureFromFile
(ConfigProperties config, ComponentLoader componentLoader) private void
maybeRegisterShutdownHook
(OpenTelemetrySdk openTelemetrySdk) private void
maybeSetAsGlobal
(OpenTelemetrySdk openTelemetrySdk) private static <I,
O1, O2>
BiFunction<I, ConfigProperties, O2> mergeCustomizer
(BiFunction<? super I, ConfigProperties, ? extends O1> first, BiFunction<? super O1, ConfigProperties, ? extends O2> second) private void
(package private) AutoConfiguredOpenTelemetrySdkBuilder
setComponentLoader
(ComponentLoader componentLoader) Sets theComponentLoader
to be used to load SPI implementations.(package private) AutoConfiguredOpenTelemetrySdkBuilder
setConfig
(ConfigProperties config) Sets theConfigProperties
to use when resolving properties for auto-configuration.(package private) AutoConfiguredOpenTelemetrySdkBuilder
setConfigPropertiesCustomizer
(Function<ConfigProperties, ConfigProperties> configPropertiesCustomizer) Adds aFunction
to invoke the with theConfigProperties
to allow customization.Sets whether the configuredOpenTelemetrySdk
should be set as the application's global instance.setServiceClassLoader
(ClassLoader serviceClassLoader) Sets theClassLoader
to be used to load SPI implementations.(package private) Thread
-
Field Details
-
logger
-
config
-
tracerProviderCustomizer
private BiFunction<SdkTracerProviderBuilder,ConfigProperties, tracerProviderCustomizerSdkTracerProviderBuilder> -
propagatorCustomizer
private BiFunction<? super TextMapPropagator,ConfigProperties, propagatorCustomizer? extends TextMapPropagator> -
spanExporterCustomizer
private BiFunction<? super SpanExporter,ConfigProperties, spanExporterCustomizer? extends SpanExporter> -
spanProcessorCustomizer
private BiFunction<? super SpanProcessor,ConfigProperties, spanProcessorCustomizer? extends SpanProcessor> -
samplerCustomizer
-
meterProviderCustomizer
private BiFunction<SdkMeterProviderBuilder,ConfigProperties, meterProviderCustomizerSdkMeterProviderBuilder> -
metricExporterCustomizer
private BiFunction<? super MetricExporter,ConfigProperties, metricExporterCustomizer? extends MetricExporter> -
metricReaderCustomizer
private BiFunction<? super MetricReader,ConfigProperties, metricReaderCustomizer? extends MetricReader> -
loggerProviderCustomizer
private BiFunction<SdkLoggerProviderBuilder,ConfigProperties, loggerProviderCustomizerSdkLoggerProviderBuilder> -
logRecordExporterCustomizer
private BiFunction<? super LogRecordExporter,ConfigProperties, logRecordExporterCustomizer? extends LogRecordExporter> -
logRecordProcessorCustomizer
private BiFunction<? super LogRecordProcessor,ConfigProperties, logRecordProcessorCustomizer? extends LogRecordProcessor> -
resourceCustomizer
-
propertiesSupplier
-
propertiesCustomizers
-
configPropertiesCustomizer
-
componentLoader
-
registerShutdownHook
private boolean registerShutdownHook -
setResultAsGlobal
private boolean setResultAsGlobal -
customized
private boolean customized
-
-
Constructor Details
-
AutoConfiguredOpenTelemetrySdkBuilder
AutoConfiguredOpenTelemetrySdkBuilder()
-
-
Method Details
-
setConfig
Sets theConfigProperties
to use when resolving properties for auto-configuration.addPropertiesSupplier(Supplier)
andaddPropertiesCustomizer(Function)
will have no effect if this method is used. -
addTracerProviderCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addTracerProviderCustomizer(BiFunction<SdkTracerProviderBuilder, ConfigProperties, SdkTracerProviderBuilder> tracerProviderCustomizer) Adds aBiFunction
to invoke the with theSdkTracerProviderBuilder
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addTracerProviderCustomizer
in interfaceAutoConfigurationCustomizer
-
addPropagatorCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addPropagatorCustomizer(BiFunction<? super TextMapPropagator, ConfigProperties, ? extends TextMapPropagator> propagatorCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredTextMapPropagator
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addPropagatorCustomizer
in interfaceAutoConfigurationCustomizer
-
addResourceCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addResourceCustomizer(BiFunction<? super Resource, ConfigProperties, ? extends Resource> resourceCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredResource
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addResourceCustomizer
in interfaceAutoConfigurationCustomizer
-
addSamplerCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addSamplerCustomizer(BiFunction<? super Sampler, ConfigProperties, ? extends Sampler> samplerCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredSampler
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addSamplerCustomizer
in interfaceAutoConfigurationCustomizer
-
addSpanExporterCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addSpanExporterCustomizer(BiFunction<? super SpanExporter, ConfigProperties, ? extends SpanExporter> spanExporterCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredSpanExporter
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addSpanExporterCustomizer
in interfaceAutoConfigurationCustomizer
-
addSpanProcessorCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addSpanProcessorCustomizer(BiFunction<? super SpanProcessor, ConfigProperties, ? extends SpanProcessor> spanProcessorCustomizer) Adds aBiFunction
to invoke for all autoconfiguredSpanProcessor
. The return value of theBiFunction
will replace the passed-in argument. In contrast toaddSpanExporterCustomizer(BiFunction)
this allows modifications to happen before batching occurs. As a result, it is possible to efficiently filter spans, add artificial spans or delay spans for enhancing them with external, delayed data.Multiple calls will execute the customizers in order.
- Specified by:
addSpanProcessorCustomizer
in interfaceAutoConfigurationCustomizer
-
addPropertiesSupplier
public AutoConfiguredOpenTelemetrySdkBuilder addPropertiesSupplier(Supplier<Map<String, String>> propertiesSupplier) Adds aSupplier
of a map of property names and values to use as defaults for theConfigProperties
used during auto-configuration. The order of precedence of properties is system properties > environment variables > the suppliers registered with this method.Multiple calls will cause properties to be merged in order, with later ones overwriting duplicate keys in earlier ones.
- Specified by:
addPropertiesSupplier
in interfaceAutoConfigurationCustomizer
-
addPropertiesCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addPropertiesCustomizer(Function<ConfigProperties, Map<String, String>> propertiesCustomizer) Adds aFunction
to invoke the with theConfigProperties
to allow customization. The return value of theFunction
will be merged into theConfigProperties
before it is used for auto-configuration, overwriting the properties that are already there.Multiple calls will cause properties to be merged in order, with later ones overwriting duplicate keys in earlier ones.
- Specified by:
addPropertiesCustomizer
in interfaceAutoConfigurationCustomizer
-
setConfigPropertiesCustomizer
AutoConfiguredOpenTelemetrySdkBuilder setConfigPropertiesCustomizer(Function<ConfigProperties, ConfigProperties> configPropertiesCustomizer) Adds aFunction
to invoke the with theConfigProperties
to allow customization.The argument to the function is the
ConfigProperties
, with theaddPropertiesCustomizer(Function)
already applied.The return value of the
Function
replace theConfigProperties
to be used. -
addMeterProviderCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addMeterProviderCustomizer(BiFunction<SdkMeterProviderBuilder, ConfigProperties, SdkMeterProviderBuilder> meterProviderCustomizer) Adds aBiFunction
to invoke the with theSdkMeterProviderBuilder
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addMeterProviderCustomizer
in interfaceAutoConfigurationCustomizer
-
addMetricExporterCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addMetricExporterCustomizer(BiFunction<? super MetricExporter, ConfigProperties, ? extends MetricExporter> metricExporterCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredSpanExporter
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addMetricExporterCustomizer
in interfaceAutoConfigurationCustomizer
-
addMetricReaderCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addMetricReaderCustomizer(BiFunction<? super MetricReader, ConfigProperties, ? extends MetricReader> readerCustomizer) Adds aBiFunction
to invoke with the autoconfiguredMetricReader
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addMetricReaderCustomizer
in interfaceAutoConfigurationCustomizer
-
addLoggerProviderCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addLoggerProviderCustomizer(BiFunction<SdkLoggerProviderBuilder, ConfigProperties, SdkLoggerProviderBuilder> loggerProviderCustomizer) Adds aBiFunction
to invoke the with theSdkLoggerProviderBuilder
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addLoggerProviderCustomizer
in interfaceAutoConfigurationCustomizer
-
addLogRecordExporterCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addLogRecordExporterCustomizer(BiFunction<? super LogRecordExporter, ConfigProperties, ? extends LogRecordExporter> logRecordExporterCustomizer) Adds aBiFunction
to invoke with the default autoconfiguredLogRecordExporter
to allow customization. The return value of theBiFunction
will replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addLogRecordExporterCustomizer
in interfaceAutoConfigurationCustomizer
-
addLogRecordProcessorCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addLogRecordProcessorCustomizer(BiFunction<? super LogRecordProcessor, ConfigProperties, ? extends LogRecordProcessor> logRecordProcessorCustomizer) Adds aBiFunction
to invoke for all autoconfiguredLogRecordProcessor
s. The return value of theBiFunction
will replace the passed-in argument. In contrast toaddLogRecordExporterCustomizer(BiFunction)
(BiFunction)} this allows modifications to happen before batching occurs. As a result, it is possible to efficiently filter logs, add artificial logs or delay logs for enhancing them with external, delayed data.Multiple calls will execute the customizers in order.
- Specified by:
addLogRecordProcessorCustomizer
in interfaceAutoConfigurationCustomizer
-
disableShutdownHook
Disable the registration of a shutdown hook to shut down the SDK when appropriate. By default, the shutdown hook is registered.Skipping the registration of the shutdown hook may cause unexpected behavior. This configuration is for SDK consumers that require control over the SDK lifecycle. In this case, alternatives must be provided by the SDK consumer to shut down the SDK.
-
setResultAsGlobal
Sets whether the configuredOpenTelemetrySdk
should be set as the application's global instance.By default,
GlobalOpenTelemetry
is not set. -
setServiceClassLoader
Sets theClassLoader
to be used to load SPI implementations. -
setComponentLoader
Sets theComponentLoader
to be used to load SPI implementations. -
build
Returns a newAutoConfiguredOpenTelemetrySdk
holding components auto-configured using the settings of thisAutoConfiguredOpenTelemetrySdkBuilder
. -
maybeConfigureFromFile
@Nullable private static AutoConfiguredOpenTelemetrySdk maybeConfigureFromFile(ConfigProperties config, ComponentLoader componentLoader) -
maybeRegisterShutdownHook
-
maybeSetAsGlobal
-
callAutoConfigureListeners
-
mergeSdkTracerProviderConfigurer
private void mergeSdkTracerProviderConfigurer() -
getConfig
-
computeConfigProperties
-
shutdownHook
-
mergeCustomizer
private static <I,O1, BiFunction<I,O2> ConfigProperties, mergeCustomizerO2> (BiFunction<? super I, ConfigProperties, ? extends O1> first, BiFunction<? super O1, ConfigProperties, ? extends O2> second) -
mergeProperties
-