All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer Maven / Gradle / Ivy

There is a newer version: 1.42.1
Show newest version
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.sdk.autoconfigure.spi;

import io.opentelemetry.context.propagation.TextMapPropagator;
import io.opentelemetry.sdk.logs.LogRecordProcessor;
import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder;
import io.opentelemetry.sdk.logs.export.LogRecordExporter;
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
import io.opentelemetry.sdk.metrics.export.MetricReader;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
import io.opentelemetry.sdk.trace.SpanProcessor;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.opentelemetry.sdk.trace.samplers.Sampler;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

/** A builder for customizing OpenTelemetry auto-configuration. */
public interface AutoConfigurationCustomizer {

  /**
   * Adds a {@link BiFunction} to invoke with the default autoconfigured {@link TextMapPropagator}
   * to allow customization. The return value of the {@link BiFunction} will replace the passed-in
   * argument.
   *
   * 

Multiple calls will execute the customizers in order. */ AutoConfigurationCustomizer addPropagatorCustomizer( BiFunction propagatorCustomizer); /** * Adds a {@link BiFunction} to invoke with the default autoconfigured {@link Resource} to allow * customization. The return value of the {@link BiFunction} will replace the passed-in argument. * *

Multiple calls will execute the customizers in order. */ AutoConfigurationCustomizer addResourceCustomizer( BiFunction resourceCustomizer); /** * Adds a {@link BiFunction} to invoke with the default autoconfigured {@link Sampler} to allow * customization. The return value of the {@link BiFunction} will replace the passed-in argument. * *

Multiple calls will execute the customizers in order. */ AutoConfigurationCustomizer addSamplerCustomizer( BiFunction samplerCustomizer); /** * Adds a {@link BiFunction} to invoke with the default autoconfigured {@link SpanExporter} to * allow customization. The return value of the {@link BiFunction} will replace the passed-in * argument. * *

Multiple calls will execute the customizers in order. */ AutoConfigurationCustomizer addSpanExporterCustomizer( BiFunction exporterCustomizer); /** * Adds a {@link BiFunction} to invoke for all autoconfigured {@link * io.opentelemetry.sdk.trace.SpanProcessor}. The return value of the {@link BiFunction} will * replace the passed-in argument. In contrast to {@link #addSpanExporterCustomizer(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. * * @since 1.33.0 */ default AutoConfigurationCustomizer addSpanProcessorCustomizer( BiFunction spanProcessorCustomizer) { return this; } /** * Adds a {@link Supplier} of a map of property names and values to use as defaults for the {@link * ConfigProperties} 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. */ AutoConfigurationCustomizer addPropertiesSupplier( Supplier> propertiesSupplier); /** * Adds a {@link Function} to invoke the with the {@link ConfigProperties} to allow customization. * The return value of the {@link Function} will be merged into the {@link ConfigProperties} * 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. * * @since 1.17.0 */ default AutoConfigurationCustomizer addPropertiesCustomizer( Function> propertiesCustomizer) { return this; } /** * Adds a {@link BiFunction} to invoke the with the {@link SdkTracerProviderBuilder} to allow * customization. The return value of the {@link BiFunction} will replace the passed-in argument. * *

Multiple calls will execute the customizers in order. * *

Note: calling {@link SdkTracerProviderBuilder#setSampler(Sampler)} inside of your * configuration function will cause any sampler customizers to be ignored that were configured * via {@link #addSamplerCustomizer(BiFunction)}. If you want to replace the default sampler, * check out {@link io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider} and * use {@link #addPropertiesSupplier(Supplier)} to set `otel.traces.sampler` to your named * sampler. * *

Similarly, calling {@link SdkTracerProviderBuilder#setResource(Resource)} inside of your * configuration function will cause any resource customizers to be ignored that were configured * via {@link #addResourceCustomizer(BiFunction)}. */ default AutoConfigurationCustomizer addTracerProviderCustomizer( BiFunction tracerProviderCustomizer) { return this; } /** * Adds a {@link BiFunction} to invoke the with the {@link SdkMeterProviderBuilder} to allow * customization. The return value of the {@link BiFunction} will replace the passed-in argument. * *

Multiple calls will execute the customizers in order. */ default AutoConfigurationCustomizer addMeterProviderCustomizer( BiFunction meterProviderCustomizer) { return this; } /** * Adds a {@link BiFunction} to invoke with the default autoconfigured {@link MetricExporter} to * allow customization. The return value of the {@link BiFunction} will replace the passed-in * argument. * *

Multiple calls will execute the customizers in order. */ @SuppressWarnings("UnusedReturnValue") default AutoConfigurationCustomizer addMetricExporterCustomizer( BiFunction exporterCustomizer) { return this; } /** * Adds a {@link BiFunction} to invoke with the autoconfigured {@link MetricReader} to allow * customization. The return value of the {@link BiFunction} will replace the passed-in argument. * *

Multiple calls will execute the customizers in order. * * @since 1.36.0 */ @SuppressWarnings("UnusedReturnValue") default AutoConfigurationCustomizer addMetricReaderCustomizer( BiFunction readerCustomizer) { return this; } /** * Adds a {@link BiFunction} to invoke the with the {@link SdkLoggerProviderBuilder} to allow * customization. The return value of the {@link BiFunction} will replace the passed-in argument. * *

Multiple calls will execute the customizers in order. * * @since 1.19.0 */ default AutoConfigurationCustomizer addLoggerProviderCustomizer( BiFunction loggerProviderCustomizer) { return this; } /** * Adds a {@link BiFunction} to invoke with the default autoconfigured {@link LogRecordExporter} * to allow customization. The return value of the {@link BiFunction} will replace the passed-in * argument. * *

Multiple calls will execute the customizers in order. * * @since 1.19.0 */ default AutoConfigurationCustomizer addLogRecordExporterCustomizer( BiFunction exporterCustomizer) { return this; } /** * Adds a {@link BiFunction} to invoke for all autoconfigured {@link * io.opentelemetry.sdk.logs.LogRecordProcessor}s. The return value of the {@link BiFunction} will * replace the passed-in argument. In contrast to {@link * #addLogRecordExporterCustomizer(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. * * @since 1.33.0 */ default AutoConfigurationCustomizer addLogRecordProcessorCustomizer( BiFunction logRecordProcessorCustomizer) { return this; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy