Class AutoConfiguredOpenTelemetrySdkBuilder
- All Implemented Interfaces:
AutoConfigurationCustomizer
- Since:
- 1.28.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ComponentLoaderprivate ConfigPropertiesprivate Function<ConfigProperties, ConfigProperties> private booleanprivate static final Loggerprivate 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 booleanprivate BiFunction<? super Resource, ConfigProperties, ? extends Resource> private BiFunction<? super Sampler, ConfigProperties, ? extends Sampler> private booleanprivate 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 aBiFunctionto invoke the with theSdkLoggerProviderBuilderto allow customization.addLogRecordExporterCustomizer(BiFunction<? super LogRecordExporter, ConfigProperties, ? extends LogRecordExporter> logRecordExporterCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredLogRecordExporterto allow customization.addLogRecordProcessorCustomizer(BiFunction<? super LogRecordProcessor, ConfigProperties, ? extends LogRecordProcessor> logRecordProcessorCustomizer) Adds aBiFunctionto invoke for all autoconfiguredLogRecordProcessors.addMeterProviderCustomizer(BiFunction<SdkMeterProviderBuilder, ConfigProperties, SdkMeterProviderBuilder> meterProviderCustomizer) Adds aBiFunctionto invoke the with theSdkMeterProviderBuilderto allow customization.addMetricExporterCustomizer(BiFunction<? super MetricExporter, ConfigProperties, ? extends MetricExporter> metricExporterCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredSpanExporterto allow customization.addMetricReaderCustomizer(BiFunction<? super MetricReader, ConfigProperties, ? extends MetricReader> readerCustomizer) Adds aBiFunctionto invoke with the autoconfiguredMetricReaderto allow customization.addPropagatorCustomizer(BiFunction<? super TextMapPropagator, ConfigProperties, ? extends TextMapPropagator> propagatorCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredTextMapPropagatorto allow customization.addPropertiesCustomizer(Function<ConfigProperties, Map<String, String>> propertiesCustomizer) Adds aFunctionto invoke the with theConfigPropertiesto allow customization.addPropertiesSupplier(Supplier<Map<String, String>> propertiesSupplier) Adds aSupplierof a map of property names and values to use as defaults for theConfigPropertiesused during auto-configuration.addResourceCustomizer(BiFunction<? super Resource, ConfigProperties, ? extends Resource> resourceCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredResourceto allow customization.addSamplerCustomizer(BiFunction<? super Sampler, ConfigProperties, ? extends Sampler> samplerCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredSamplerto allow customization.addSpanExporterCustomizer(BiFunction<? super SpanExporter, ConfigProperties, ? extends SpanExporter> spanExporterCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredSpanExporterto allow customization.addSpanProcessorCustomizer(BiFunction<? super SpanProcessor, ConfigProperties, ? extends SpanProcessor> spanProcessorCustomizer) Adds aBiFunctionto invoke for all autoconfiguredSpanProcessor.addTracerProviderCustomizer(BiFunction<SdkTracerProviderBuilder, ConfigProperties, SdkTracerProviderBuilder> tracerProviderCustomizer) Adds aBiFunctionto invoke the with theSdkTracerProviderBuilderto allow customization.build()Returns a newAutoConfiguredOpenTelemetrySdkholding components auto-configured using the settings of thisAutoConfiguredOpenTelemetrySdkBuilder.(package private) voidcallAutoConfigureListeners(SpiHelper spiHelper, OpenTelemetrySdk openTelemetrySdk) private ConfigPropertiesDisable the registration of a shutdown hook to shut down the SDK when appropriate.private ConfigPropertiesprivate static AutoConfiguredOpenTelemetrySdkmaybeConfigureFromFile(ConfigProperties config, ComponentLoader componentLoader) private voidmaybeRegisterShutdownHook(OpenTelemetrySdk openTelemetrySdk) private voidmaybeSetAsGlobal(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) AutoConfiguredOpenTelemetrySdkBuildersetComponentLoader(ComponentLoader componentLoader) Sets theComponentLoaderto be used to load SPI implementations.(package private) AutoConfiguredOpenTelemetrySdkBuildersetConfig(ConfigProperties config) Sets theConfigPropertiesto use when resolving properties for auto-configuration.(package private) AutoConfiguredOpenTelemetrySdkBuildersetConfigPropertiesCustomizer(Function<ConfigProperties, ConfigProperties> configPropertiesCustomizer) Adds aFunctionto invoke the with theConfigPropertiesto allow customization.Sets whether the configuredOpenTelemetrySdkshould be set as the application's global instance.setServiceClassLoader(ClassLoader serviceClassLoader) Sets theClassLoaderto 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 theConfigPropertiesto 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 aBiFunctionto invoke the with theSdkTracerProviderBuilderto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addTracerProviderCustomizerin interfaceAutoConfigurationCustomizer
-
addPropagatorCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addPropagatorCustomizer(BiFunction<? super TextMapPropagator, ConfigProperties, ? extends TextMapPropagator> propagatorCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredTextMapPropagatorto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addPropagatorCustomizerin interfaceAutoConfigurationCustomizer
-
addResourceCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addResourceCustomizer(BiFunction<? super Resource, ConfigProperties, ? extends Resource> resourceCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredResourceto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addResourceCustomizerin interfaceAutoConfigurationCustomizer
-
addSamplerCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addSamplerCustomizer(BiFunction<? super Sampler, ConfigProperties, ? extends Sampler> samplerCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredSamplerto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addSamplerCustomizerin interfaceAutoConfigurationCustomizer
-
addSpanExporterCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addSpanExporterCustomizer(BiFunction<? super SpanExporter, ConfigProperties, ? extends SpanExporter> spanExporterCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredSpanExporterto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addSpanExporterCustomizerin interfaceAutoConfigurationCustomizer
-
addSpanProcessorCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addSpanProcessorCustomizer(BiFunction<? super SpanProcessor, ConfigProperties, ? extends SpanProcessor> spanProcessorCustomizer) Adds aBiFunctionto invoke for all autoconfiguredSpanProcessor. The return value of theBiFunctionwill 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:
addSpanProcessorCustomizerin interfaceAutoConfigurationCustomizer
-
addPropertiesSupplier
public AutoConfiguredOpenTelemetrySdkBuilder addPropertiesSupplier(Supplier<Map<String, String>> propertiesSupplier) Adds aSupplierof a map of property names and values to use as defaults for theConfigPropertiesused 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:
addPropertiesSupplierin interfaceAutoConfigurationCustomizer
-
addPropertiesCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addPropertiesCustomizer(Function<ConfigProperties, Map<String, String>> propertiesCustomizer) Adds aFunctionto invoke the with theConfigPropertiesto allow customization. The return value of theFunctionwill be merged into theConfigPropertiesbefore 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:
addPropertiesCustomizerin interfaceAutoConfigurationCustomizer
-
setConfigPropertiesCustomizer
AutoConfiguredOpenTelemetrySdkBuilder setConfigPropertiesCustomizer(Function<ConfigProperties, ConfigProperties> configPropertiesCustomizer) Adds aFunctionto invoke the with theConfigPropertiesto allow customization.The argument to the function is the
ConfigProperties, with theaddPropertiesCustomizer(Function)already applied.The return value of the
Functionreplace theConfigPropertiesto be used. -
addMeterProviderCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addMeterProviderCustomizer(BiFunction<SdkMeterProviderBuilder, ConfigProperties, SdkMeterProviderBuilder> meterProviderCustomizer) Adds aBiFunctionto invoke the with theSdkMeterProviderBuilderto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addMeterProviderCustomizerin interfaceAutoConfigurationCustomizer
-
addMetricExporterCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addMetricExporterCustomizer(BiFunction<? super MetricExporter, ConfigProperties, ? extends MetricExporter> metricExporterCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredSpanExporterto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addMetricExporterCustomizerin interfaceAutoConfigurationCustomizer
-
addMetricReaderCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addMetricReaderCustomizer(BiFunction<? super MetricReader, ConfigProperties, ? extends MetricReader> readerCustomizer) Adds aBiFunctionto invoke with the autoconfiguredMetricReaderto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addMetricReaderCustomizerin interfaceAutoConfigurationCustomizer
-
addLoggerProviderCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addLoggerProviderCustomizer(BiFunction<SdkLoggerProviderBuilder, ConfigProperties, SdkLoggerProviderBuilder> loggerProviderCustomizer) Adds aBiFunctionto invoke the with theSdkLoggerProviderBuilderto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addLoggerProviderCustomizerin interfaceAutoConfigurationCustomizer
-
addLogRecordExporterCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addLogRecordExporterCustomizer(BiFunction<? super LogRecordExporter, ConfigProperties, ? extends LogRecordExporter> logRecordExporterCustomizer) Adds aBiFunctionto invoke with the default autoconfiguredLogRecordExporterto allow customization. The return value of theBiFunctionwill replace the passed-in argument.Multiple calls will execute the customizers in order.
- Specified by:
addLogRecordExporterCustomizerin interfaceAutoConfigurationCustomizer
-
addLogRecordProcessorCustomizer
public AutoConfiguredOpenTelemetrySdkBuilder addLogRecordProcessorCustomizer(BiFunction<? super LogRecordProcessor, ConfigProperties, ? extends LogRecordProcessor> logRecordProcessorCustomizer) Adds aBiFunctionto invoke for all autoconfiguredLogRecordProcessors. The return value of theBiFunctionwill 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:
addLogRecordProcessorCustomizerin 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 configuredOpenTelemetrySdkshould be set as the application's global instance.By default,
GlobalOpenTelemetryis not set. -
setServiceClassLoader
Sets theClassLoaderto be used to load SPI implementations. -
setComponentLoader
Sets theComponentLoaderto be used to load SPI implementations. -
build
Returns a newAutoConfiguredOpenTelemetrySdkholding 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
-