Class SdkMeter
java.lang.Object
io.opentelemetry.sdk.metrics.SdkMeter
- All Implemented Interfaces:
Meter
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Objectprivate final List<CallbackRegistration> private final Objectprivate final InstrumentationScopeInfoprivate static final Loggerprivate final booleanprivate final MeterProviderSharedStateprivate static final Stringprivate static final Meterprivate final Map<RegisteredReader, MetricStorageRegistry> private static final PatternInstrument names MUST conform to the following syntax. -
Constructor Summary
ConstructorsConstructorDescriptionSdkMeter(MeterProviderSharedState meterProviderSharedState, InstrumentationScopeInfo instrumentationScopeInfo, List<RegisteredReader> registeredReaders, MeterConfig meterConfig) -
Method Summary
Modifier and TypeMethodDescriptionbatchCallback(Runnable callback, ObservableMeasurement observableMeasurement, ObservableMeasurement... additionalMeasurements) Constructs a batch callback.(package private) static booleanCheck if the instrument name is valid.(package private) Collection<MetricData> collectAll(RegisteredReader registeredReader, long epochNanos) Collect all metrics for the meter.counterBuilder(String name) Constructs a Counter instrument.gaugeBuilder(String name) Constructs an Asynchronous Gauge instrument.(package private) InstrumentationScopeInfohistogramBuilder(String name) Constructs a Histogram instrument.(package private) boolean(package private) voidregisterCallback(CallbackRegistration callbackRegistration) Register the callback.(package private) SdkObservableMeasurementregisterObservableMeasurement(InstrumentDescriptor instrumentDescriptor) Register new asynchronous storage associated with a given instrument.(package private) WriteableMetricStorageregisterSynchronousMetricStorage(InstrumentDescriptor instrument) Registers new synchronous storage associated with a given instrument.(package private) voidremoveCallback(CallbackRegistration callbackRegistration) Unregister the callback.(package private) voidReset the meter, clearing all registered callbacks and storages.toString()upDownCounterBuilder(String name) Constructs an UpDownCounter instrument.
-
Field Details
-
logger
-
VALID_INSTRUMENT_NAME_PATTERN
Instrument names MUST conform to the following syntax.- They are not null or empty strings.
- They are case-insensitive, ASCII strings.
- The first character must be an alphabetic character.
- Subsequent characters must belong to the alphanumeric characters, '_', '.', '/', and '-'.
- They can have a maximum length of 255 characters.
-
NOOP_METER
-
NOOP_INSTRUMENT_NAME
- See Also:
-
collectLock
-
callbackLock
-
callbackRegistrations
-
instrumentationScopeInfo
-
readerStorageRegistries
-
meterEnabled
private final boolean meterEnabled
-
-
Constructor Details
-
Method Details
-
getInstrumentationScopeInfo
InstrumentationScopeInfo getInstrumentationScopeInfo() -
collectAll
Collect all metrics for the meter. -
resetForTest
void resetForTest()Reset the meter, clearing all registered callbacks and storages. -
counterBuilder
Description copied from interface:MeterConstructs a Counter instrument.This is used to build both synchronous instruments and asynchronous instruments (i.e. callbacks).
- Specified by:
counterBuilderin interfaceMeter- Parameters:
name- the name of the Counter. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.- Returns:
- a builder for configuring a Counter instrument. Defaults to recording long values, but may be changed.
- See Also:
-
upDownCounterBuilder
Description copied from interface:MeterConstructs an UpDownCounter instrument.This is used to build both synchronous instruments and asynchronous instruments (i.e. callbacks).
- Specified by:
upDownCounterBuilderin interfaceMeter- Parameters:
name- the name of the UpDownCounter. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.- Returns:
- a builder for configuring an UpDownCounter instrument. Defaults to recording long values, but may be changed.
- See Also:
-
histogramBuilder
Description copied from interface:MeterConstructs a Histogram instrument.- Specified by:
histogramBuilderin interfaceMeter- Parameters:
name- the name of the Histogram. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.- Returns:
- a builder for configuring a Histogram synchronous instrument. Defaults to recording double values, but may be changed.
- See Also:
-
gaugeBuilder
Description copied from interface:MeterConstructs an Asynchronous Gauge instrument.- Specified by:
gaugeBuilderin interfaceMeter- Parameters:
name- the name of the Gauge. Instrument names must consist of 255 or fewer characters including alphanumeric, _, ., -, /, and start with a letter.- Returns:
- a builder used for configuring a Gauge instrument. Defaults to recording double values, but may be changed.
- See Also:
-
batchCallback
public BatchCallback batchCallback(Runnable callback, ObservableMeasurement observableMeasurement, ObservableMeasurement... additionalMeasurements) Description copied from interface:MeterConstructs a batch callback.Batch callbacks allow a single callback to observe measurements for multiple asynchronous instruments.
The callback will be called when the instruments are being observed.
Callbacks are expected to abide by the following restrictions:
- Run in a finite amount of time.
- Safe to call repeatedly, across multiple threads.
- Only observe values to registered instruments (i.e.
observableMeasurementandadditionalMeasurements
- Specified by:
batchCallbackin interfaceMeter- Parameters:
callback- a callback used to observe values on-demand.observableMeasurement- Instruments for which the callback may observe values.additionalMeasurements- Instruments for which the callback may observe values.
-
removeCallback
Unregister the callback.Callbacks are originally registered via
registerCallback(CallbackRegistration). -
registerCallback
Register the callback.The callback will be invoked once per collection until unregistered via
removeCallback(CallbackRegistration). -
isMeterEnabled
boolean isMeterEnabled() -
registerSynchronousMetricStorage
Registers new synchronous storage associated with a given instrument. -
registerObservableMeasurement
Register new asynchronous storage associated with a given instrument. -
toString
-
checkValidInstrumentName
Check if the instrument name is valid. If invalid, log a warning.
-