Package io.opentelemetry.api.metrics
Interface Meter
@ThreadSafe
public interface Meter
Provides instruments used to produce metrics.
Instruments are obtained through builders provided by this interface. Each builder has a default "type" associated with recordings that may be changed.
A Meter is generally associated with an instrumentation scope, e.g. "I monitor apache httpclient".
Choosing an instrument can be hard, but here's a rule of thumb for selecting the right instrument:
- I want to count something.
- The value is always increasing / I want to track its rate.
UsecounterBuilder(String)
- The value is not always increasing.
UseupDownCounterBuilder(String)
- The value is always increasing / I want to track its rate.
- I want to time something, or record measurements where the statistics are important
(e.g. latency).
UsehistogramBuilder(String)
- I want to measure something by sampling a value stored elsewhere.
UsegaugeBuilder(String)
-
Method Summary
Modifier and TypeMethodDescriptioncounterBuilder
(String name) Constructs a counter instrument.gaugeBuilder
(String name) Constructs an asynchronous gauge.histogramBuilder
(String name) Constructs a Histogram instrument.upDownCounterBuilder
(String name) Constructs an up-down-counter instrument.
-
Method Details
-
counterBuilder
Constructs a counter instrument.This is used to build both synchronous (in-context) instruments and asynchronous (callback) instruments.
- Parameters:
name
- the name used for the counter.- Returns:
- a builder for configuring a new Counter instrument. Defaults to recording long values, but may be changed.
-
upDownCounterBuilder
Constructs an up-down-counter instrument.This is used to build both synchronous (in-context) instruments and asynchronous (callback) instruments.
- Parameters:
name
- the name used for the counter.- Returns:
- a builder for configuring a new Counter synchronous instrument. Defaults to recording long values, but may be changed.
-
histogramBuilder
Constructs a Histogram instrument.- Parameters:
name
- the name used for the counter.- Returns:
- a builder for configuring a new Histogram synchronous instrument. Defaults to recording double values, but may be changed.
-
gaugeBuilder
Constructs an asynchronous gauge.- Returns:
- a builder used for configuring how to report gauge measurements on demand.
-