[−][src]Trait opentelemetry::api::metrics::Meter
Meter is an interface to the metrics portion of the OpenTelemetry SDK.
The Meter interface allows creating of a registered metric instrument using methods specific to each kind of metric. There are six constructors representing the three kinds of instrument taking either floating point or integer inputs, see the detailed design below.
Binding instruments to a single Meter instance has two benefits:
- Instruments can be exported from the zero state, prior to first use, with no explicit Register call
- The component name provided by the named Meter satisfies a namespace requirement
The recommended practice is to define structures to contain the instruments in use and keep references only to the instruments that are specifically needed.
We recognize that many existing metric systems support allocating metric instruments statically and providing the Meter interface at the time of use. In this example, typical of statsd clients, existing code may not be structured with a convenient place to store new metric instruments. Where this becomes a burden, it is recommended to use the global meter factory to construct a static named Meter, to construct metric instruments.
The situation is similar for users of Prometheus clients, where instruments are allocated statically and there is an implicit global. Such code may not have access to the appropriate Meter where instruments are defined. Where this becomes a burden, it is recommended to use the global meter factory to construct a static named Meter, to construct metric instruments.
Applications are expected to construct long-lived instruments. Instruments are considered permanent for the lifetime of a SDK, there is no method to delete them.
Associated Types
type LabelSet: LabelSet
The LabelSet
data type for this meter.
type I64Counter: Counter<i64, Self::LabelSet>
The I64Counter
data type for this meter.
type F64Counter: Counter<f64, Self::LabelSet>
The F64Counter
data type for this meter.
type I64Gauge: Gauge<i64, Self::LabelSet>
The I64Gauge
data type for this meter.
type F64Gauge: Gauge<f64, Self::LabelSet>
The F64Gauge
data type for this meter.
type I64Measure: Measure<i64, Self::LabelSet>
The I64Measure
data type for this meter.
type F64Measure: Measure<f64, Self::LabelSet>
The F64Measure
data type for this meter.
Required methods
fn labels(&self, key_values: Vec<KeyValue>) -> Self::LabelSet
Returns a reference to a set of labels that cannot be read by the application.
fn new_i64_counter<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::I64Counter
&self,
name: S,
opts: MetricOptions
) -> Self::I64Counter
Creates a new i64
counter with a given name and customized with passed options.
fn new_f64_counter<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::F64Counter
&self,
name: S,
opts: MetricOptions
) -> Self::F64Counter
Creates a new f64
counter with a given name and customized with passed options.
fn new_i64_gauge<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::I64Gauge
&self,
name: S,
opts: MetricOptions
) -> Self::I64Gauge
Creates a new i64
gauge with a given name and customized with passed options.
fn new_f64_gauge<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::F64Gauge
&self,
name: S,
opts: MetricOptions
) -> Self::F64Gauge
Creates a new f64
gauge with a given name and customized with passed options.
fn new_i64_measure<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::I64Measure
&self,
name: S,
opts: MetricOptions
) -> Self::I64Measure
Creates a new i64
measure with a given name and customized with passed options.
fn new_f64_measure<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::F64Measure
&self,
name: S,
opts: MetricOptions
) -> Self::F64Measure
Creates a new f64
measure with a given name and customized with passed options.
fn record_batch<M: IntoIterator<Item = Measurement<Self::LabelSet>>>(
&self,
label_set: &Self::LabelSet,
measurements: M
)
&self,
label_set: &Self::LabelSet,
measurements: M
)
Atomically records a batch of measurements.
Implementors
impl Meter for NoopMeter
[src]
type LabelSet = NoopLabelSet
type I64Counter = NoopCounter<i64>
type F64Counter = NoopCounter<f64>
type I64Gauge = NoopGauge<i64>
type F64Gauge = NoopGauge<f64>
type I64Measure = NoopMeasure<i64>
type F64Measure = NoopMeasure<f64>
fn labels(&self, _key_values: Vec<KeyValue>) -> Self::LabelSet
[src]
Returns a no-op NoopLabelSet
.
fn new_i64_counter<S: Into<String>>(
&self,
_name: S,
_opts: MetricOptions
) -> Self::I64Counter
[src]
&self,
_name: S,
_opts: MetricOptions
) -> Self::I64Counter
Returns a no-op I64Counter
instance.
fn new_f64_counter<S: Into<String>>(
&self,
_name: S,
_opts: MetricOptions
) -> Self::F64Counter
[src]
&self,
_name: S,
_opts: MetricOptions
) -> Self::F64Counter
Returns a no-op F64Counter
instance.
fn new_i64_gauge<S: Into<String>>(
&self,
_name: S,
_opts: MetricOptions
) -> Self::I64Gauge
[src]
&self,
_name: S,
_opts: MetricOptions
) -> Self::I64Gauge
Returns a no-op I64Gauge
instance.
fn new_f64_gauge<S: Into<String>>(
&self,
_name: S,
_opts: MetricOptions
) -> Self::F64Gauge
[src]
&self,
_name: S,
_opts: MetricOptions
) -> Self::F64Gauge
Returns a no-op F64Gauge
instance.
fn new_i64_measure<S: Into<String>>(
&self,
_name: S,
_opts: MetricOptions
) -> Self::I64Measure
[src]
&self,
_name: S,
_opts: MetricOptions
) -> Self::I64Measure
Returns a no-op I64Measure
instance.
fn new_f64_measure<S: Into<String>>(
&self,
_name: S,
_opts: MetricOptions
) -> Self::F64Measure
[src]
&self,
_name: S,
_opts: MetricOptions
) -> Self::F64Measure
Returns a no-op F64Measure
instance.
fn record_batch<M: IntoIterator<Item = Measurement<NoopLabelSet>>>(
&self,
_label_set: &NoopLabelSet,
_measurements: M
)
[src]
&self,
_label_set: &NoopLabelSet,
_measurements: M
)
Ignores batch recordings
impl Meter for Meter
[src]
type LabelSet = LabelSet
The label set used by this Meter
.
type I64Counter = IntCounterVec
This implementation of api::Meter
produces prometheus::IntCounterVec;
instances.
type F64Counter = CounterVec
This implementation of api::Meter
produces prometheus::CounterVec;
instances.
type I64Gauge = IntGaugeVec
This implementation of api::Meter
produces prometheus::IntGaugeVec;
instances.
type F64Gauge = GaugeVec
This implementation of api::Meter
produces prometheus::GaugeVec;
instances.
type I64Measure = IntMeasure
This implementation of api::Meter
produces prometheus::IntMeasure;
instances.
type F64Measure = HistogramVec
This implementation of api::Meter
produces prometheus::HistogramVec;
instances.
fn labels(&self, key_values: Vec<KeyValue>) -> Self::LabelSet
[src]
Builds a LabelSet
from KeyValue
s.
fn new_i64_counter<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::I64Counter
[src]
&self,
name: S,
opts: MetricOptions
) -> Self::I64Counter
Creates a new i64
counter with a given name and customized with passed options.
fn new_f64_counter<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::F64Counter
[src]
&self,
name: S,
opts: MetricOptions
) -> Self::F64Counter
Creates a new f64
counter with a given name and customized with passed options.
fn new_i64_gauge<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::I64Gauge
[src]
&self,
name: S,
opts: MetricOptions
) -> Self::I64Gauge
Creates a new i64
gauge with a given name and customized with passed options.
fn new_f64_gauge<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::F64Gauge
[src]
&self,
name: S,
opts: MetricOptions
) -> Self::F64Gauge
Creates a new f64
gauge with a given name and customized with passed options.
fn new_i64_measure<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::I64Measure
[src]
&self,
name: S,
opts: MetricOptions
) -> Self::I64Measure
Creates a new i64
measure with a given name and customized with passed options.
fn new_f64_measure<S: Into<String>>(
&self,
name: S,
opts: MetricOptions
) -> Self::F64Measure
[src]
&self,
name: S,
opts: MetricOptions
) -> Self::F64Measure
Creates a new f64
measure with a given name and customized with passed options.
fn record_batch<M: IntoIterator<Item = Measurement<Self::LabelSet>>>(
&self,
label_set: &Self::LabelSet,
measurements: M
)
[src]
&self,
label_set: &Self::LabelSet,
measurements: M
)
Records a batch of measurements.