Interface OpenTelemetry
-
- All Known Implementing Classes:
DefaultOpenTelemetry
public interface OpenTelemetry
The 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
,TracerProviderFactory
orMeterProviderFactory
found on the classpath, or otherwise will be default, with no-op behavior.If using the OpenTelemetry SDK, you may want to instantiate the
OpenTelemetry
to provide configuration, for example ofResource
orSampler
. SeeOpenTelemetrySdk
andOpenTelemetrySdk.builder
for information on how to construct the SDKOpenTelemetry
.- See Also:
TracerProvider
,MeterProvider
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static OpenTelemetry
get()
Returns the registered globalOpenTelemetry
.static Meter
getGlobalMeter(String instrumentationName)
Gets or creates a named meter instance from the globally registeredMeterProvider
.static Meter
getGlobalMeter(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned meter instance from the globally registeredMeterProvider
.static MeterProvider
getGlobalMeterProvider()
Returns the globally registeredMeterProvider
.static io.opentelemetry.context.propagation.ContextPropagators
getGlobalPropagators()
Returns the globally registeredContextPropagators
for remote propagation of a context.static Tracer
getGlobalTracer(String instrumentationName)
Gets or creates a named tracer instance from the globally registeredTracerProvider
.static Tracer
getGlobalTracer(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned tracer instance from the globally registeredTracerProvider
.static TracerProvider
getGlobalTracerProvider()
Returns the globally registeredTracerProvider
.default Meter
getMeter(String instrumentationName)
Gets or creates a named meter instance from theMeterProvider
in thisOpenTelemetry
.default Meter
getMeter(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned meter instance from theMeterProvider
in thisOpenTelemetry
.MeterProvider
getMeterProvider()
Returns theMeterProvider
for thisOpenTelemetry
.io.opentelemetry.context.propagation.ContextPropagators
getPropagators()
Returns theContextPropagators
for thisOpenTelemetry
.default Tracer
getTracer(String instrumentationName)
Gets or creates a named tracer instance from theTracerProvider
for thisOpenTelemetry
.default Tracer
getTracer(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned tracer instance from theTracerProvider
in thisOpenTelemetry
.TracerProvider
getTracerProvider()
Returns theTracerProvider
for thisOpenTelemetry
.static void
set(OpenTelemetry openTelemetry)
Sets theOpenTelemetry
that should be the global instance.static void
setGlobalPropagators(io.opentelemetry.context.propagation.ContextPropagators propagators)
Sets the globally registeredContextPropagators
for remote propagation of a context.OpenTelemetryBuilder<?>
toBuilder()
Returns a newOpenTelemetryBuilder
with 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 defaultOpenTelemetry
composed of functionality anyOpenTelemetryFactory
,TracerProviderFactory
orMeterProviderFactory
, 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 theOpenTelemetry
that should be the global instance. Future calls toget()
will return the providedOpenTelemetry
instance. This should be called once as early as possible in your application initialization logic, often in astatic
block 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 registeredContextPropagators
for remote propagation of a context.
-
setGlobalPropagators
static void setGlobalPropagators(io.opentelemetry.context.propagation.ContextPropagators propagators)
Sets the globally registeredContextPropagators
for remote propagation of a context.
-
getTracerProvider
TracerProvider getTracerProvider()
Returns theTracerProvider
for thisOpenTelemetry
.
-
getTracer
default Tracer getTracer(String instrumentationName)
Gets or creates a named tracer instance from theTracerProvider
for 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 theTracerProvider
in 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 theMeterProvider
for thisOpenTelemetry
.
-
getMeter
default Meter getMeter(String instrumentationName)
Gets or creates a named meter instance from theMeterProvider
in 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 theMeterProvider
in 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 theContextPropagators
for thisOpenTelemetry
.
-
toBuilder
OpenTelemetryBuilder<?> toBuilder()
Returns a newOpenTelemetryBuilder
with the configuration of thisOpenTelemetry
.
-
-