Package io.opentelemetry.api.metrics
Class GlobalMeterProvider
- java.lang.Object
-
- io.opentelemetry.api.metrics.GlobalMeterProvider
-
public final class GlobalMeterProvider extends Object
IMPORTANT: This is a temporary class, and solution for the metrics package until it will be marked as stable.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MeterProvider
get()
Returns the globally registeredMeterProvider
.static Meter
getMeter(String instrumentationName)
Gets or creates a named meter instance from the globally registeredMeterProvider
.static Meter
getMeter(String instrumentationName, String instrumentationVersion)
Gets or creates a named and versioned meter instance from the globally registeredMeterProvider
.static MeterBuilder
meterBuilder(String instrumentationName)
Creates aMeterBuilder
for a named meter instance.static void
set(MeterProvider meterProvider)
Sets theMeterProvider
that should be the global instance.
-
-
-
Method Detail
-
get
public static MeterProvider get()
Returns the globally registeredMeterProvider
.
-
set
public static void set(MeterProvider meterProvider)
Sets theMeterProvider
that should be the global instance. Future calls toget()
will return the providedMeterProvider
instance. This should be called once as early as possible in your application initialization logic, often in astatic
block in your main class.
-
getMeter
public static Meter getMeter(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.
-
getMeter
public static Meter getMeter(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.
-
meterBuilder
public static MeterBuilder meterBuilder(String instrumentationName)
Creates aMeterBuilder
for a named meter instance.This is a shortcut method for
get().meterBuilder(instrumentationName)
- Parameters:
instrumentationName
- The name of the instrumentation library, not the name of the instrument*ed* library.- Returns:
- a MeterBuilder instance.
- Since:
- 1.4.0
-
-