Interface OpenTelemetry
-
public interface OpenTelemetryThe entrypoint to telemetry functionality for tracing, metrics and baggage.A global singleton can be retrieved by
get(). The default for the returnedOpenTelemetry, if none has been set viaset(OpenTelemetry), will be created with anyOpenTelemetryFactory,TracerProviderFactoryorMeterProviderFactoryfound on the classpath, or otherwise will be default, with no-op behavior.If using the OpenTelemetry SDK, you may want to instantiate the
OpenTelemetryto provide configuration, for example ofResourceorSampler. SeeOpenTelemetrySdkandOpenTelemetrySdk.builderfor information on how to construct the SDKOpenTelemetry.- See Also:
TracerProvider,MeterProvider
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceOpenTelemetry.Builder<T extends OpenTelemetry.Builder<T>>A builder of an implementation of the OpenTelemetry API.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static OpenTelemetryget()Returns the registered globalOpenTelemetry.static MetergetGlobalMeter(String instrumentationName)Gets or creates a named meter instance from the globally registeredMeterProvider.static MetergetGlobalMeter(String instrumentationName, String instrumentationVersion)Gets or creates a named and versioned meter instance from the globally registeredMeterProvider.static MeterProvidergetGlobalMeterProvider()Returns the globally registeredMeterProvider.static io.opentelemetry.context.propagation.ContextPropagatorsgetGlobalPropagators()Returns the globally registeredContextPropagatorsfor remote propagation of a context.static TracergetGlobalTracer(String instrumentationName)Gets or creates a named tracer instance from the globally registeredTracerProvider.static TracergetGlobalTracer(String instrumentationName, String instrumentationVersion)Gets or creates a named and versioned tracer instance from the globally registeredTracerProvider.static TracerProvidergetGlobalTracerProvider()Returns the globally registeredTracerProvider.default MetergetMeter(String instrumentationName)Gets or creates a named meter instance from theMeterProviderin thisOpenTelemetry.default MetergetMeter(String instrumentationName, String instrumentationVersion)Gets or creates a named and versioned meter instance from theMeterProviderin thisOpenTelemetry.MeterProvidergetMeterProvider()Returns theMeterProviderfor thisOpenTelemetry.io.opentelemetry.context.propagation.ContextPropagatorsgetPropagators()Returns theContextPropagatorsfor thisOpenTelemetry.default TracergetTracer(String instrumentationName)Gets or creates a named tracer instance from theTracerProviderfor thisOpenTelemetry.default TracergetTracer(String instrumentationName, String instrumentationVersion)Gets or creates a named and versioned tracer instance from theTracerProviderin thisOpenTelemetry.TracerProvidergetTracerProvider()Returns theTracerProviderfor thisOpenTelemetry.static voidset(OpenTelemetry openTelemetry)Sets theOpenTelemetrythat should be the global instance.static voidsetGlobalPropagators(io.opentelemetry.context.propagation.ContextPropagators propagators)Sets the globally registeredContextPropagatorsfor remote propagation of a context.OpenTelemetry.Builder<?>toBuilder()Returns a newOpenTelemetry.Builderwith the configuration of thisOpenTelemetry.
-
-
-
Method Detail
-
get
static OpenTelemetry get()
Returns the registered globalOpenTelemetry. If no call toset(OpenTelemetry)has been made so far, a defaultOpenTelemetrycomposed of functionality anyOpenTelemetryFactory,TracerProviderFactoryorMeterProviderFactory, found on the classpath, or otherwise will be default, with no-op behavior.- Throws:
IllegalStateException- if a provider has been specified by system property using the interface FQCN but the specified provider cannot be found.
-
set
static void set(OpenTelemetry openTelemetry)
Sets theOpenTelemetrythat should be the global instance. Future calls toget()will return the providedOpenTelemetryinstance. This should be called once as early as possible in your application initialization logic, often in astaticblock in your main class.
-
getGlobalTracerProvider
static TracerProvider getGlobalTracerProvider()
Returns the globally registeredTracerProvider.
-
getGlobalTracer
static Tracer getGlobalTracer(String instrumentationName)
Gets or creates a named tracer instance from the globally registeredTracerProvider.This is a shortcut method for
getGlobalTracerProvider().get(instrumentationName)- Parameters:
instrumentationName- The name of the instrumentation library, not the name of the instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null.- Returns:
- a tracer instance.
-
getGlobalTracer
static Tracer getGlobalTracer(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned tracer instance from the globally registeredTracerProvider.This is a shortcut method for
getGlobalTracerProvider().get(instrumentationName, instrumentationVersion)- Parameters:
instrumentationName- The name of the instrumentation library, not the name of the instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null.instrumentationVersion- The version of the instrumentation library (e.g., "semver:1.0.0").- Returns:
- a tracer instance.
-
getGlobalMeterProvider
static MeterProvider getGlobalMeterProvider()
Returns the globally registeredMeterProvider.
-
getGlobalMeter
static Meter getGlobalMeter(String instrumentationName)
Gets or creates a named meter instance from the globally registeredMeterProvider.This is a shortcut method for
getGlobalMeterProvider().get(instrumentationName)- Parameters:
instrumentationName- The name of the instrumentation library, not the name of the instrument*ed* library.- Returns:
- a tracer instance.
-
getGlobalMeter
static Meter getGlobalMeter(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned meter instance from the globally registeredMeterProvider.This is a shortcut method for
getGlobalMeterProvider().get(instrumentationName, instrumentationVersion)- Parameters:
instrumentationName- The name of the instrumentation library, not the name of the instrument*ed* library.instrumentationVersion- The version of the instrumentation library.- Returns:
- a tracer instance.
-
getGlobalPropagators
static io.opentelemetry.context.propagation.ContextPropagators getGlobalPropagators()
Returns the globally registeredContextPropagatorsfor remote propagation of a context.
-
setGlobalPropagators
static void setGlobalPropagators(io.opentelemetry.context.propagation.ContextPropagators propagators)
Sets the globally registeredContextPropagatorsfor remote propagation of a context.
-
getTracerProvider
TracerProvider getTracerProvider()
Returns theTracerProviderfor thisOpenTelemetry.
-
getTracer
default Tracer getTracer(String instrumentationName)
Gets or creates a named tracer instance from theTracerProviderfor thisOpenTelemetry.- Parameters:
instrumentationName- The name of the instrumentation library, not the name of the instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null.- Returns:
- a tracer instance.
-
getTracer
default Tracer getTracer(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned tracer instance from theTracerProviderin thisOpenTelemetry.- Parameters:
instrumentationName- The name of the instrumentation library, not the name of the instrument*ed* library (e.g., "io.opentelemetry.contrib.mongodb"). Must not be null.instrumentationVersion- The version of the instrumentation library (e.g., "semver:1.0.0").- Returns:
- a tracer instance.
-
getMeterProvider
MeterProvider getMeterProvider()
Returns theMeterProviderfor thisOpenTelemetry.
-
getMeter
default Meter getMeter(String instrumentationName)
Gets or creates a named meter instance from theMeterProviderin thisOpenTelemetry.- Parameters:
instrumentationName- The name of the instrumentation library, not the name of the instrument*ed* library.- Returns:
- a tracer instance.
-
getMeter
default Meter getMeter(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned meter instance from theMeterProviderin thisOpenTelemetry.- Parameters:
instrumentationName- The name of the instrumentation library, not the name of the instrument*ed* library.instrumentationVersion- The version of the instrumentation library.- Returns:
- a tracer instance.
-
getPropagators
io.opentelemetry.context.propagation.ContextPropagators getPropagators()
Returns theContextPropagatorsfor thisOpenTelemetry.
-
toBuilder
OpenTelemetry.Builder<?> toBuilder()
Returns a newOpenTelemetry.Builderwith the configuration of thisOpenTelemetry.
-
-