pub struct MeterProviderBuilder { /* private fields */ }
Expand description
Configuration options for a MeterProvider.
Implementations§
Source§impl MeterProviderBuilder
impl MeterProviderBuilder
Sourcepub fn with_resource(self, resource: Resource) -> Self
pub fn with_resource(self, resource: Resource) -> Self
Associates a Resource with a MeterProvider.
This Resource represents the entity producing telemetry and is associated with all Meters the MeterProvider will create.
By default, if this option is not used, the default Resource will be used.
Sourcepub fn with_reader<T: MetricReader>(self, reader: T) -> Self
pub fn with_reader<T: MetricReader>(self, reader: T) -> Self
Associates a MetricReader with a MeterProvider. `MeterProviderBuilder::with_periodic_exporter() can be used to add a PeriodicReader which is the most common use case.
A MeterProvider will export no metrics without MetricReader added.
Sourcepub fn with_periodic_exporter<T>(self, exporter: T) -> Selfwhere
T: PushMetricExporter,
pub fn with_periodic_exporter<T>(self, exporter: T) -> Selfwhere
T: PushMetricExporter,
Adds a PushMetricExporter
to the MeterProvider
and configures it
to export metrics at fixed intervals (60 seconds) using a
PeriodicReader
.
To customize the export interval, set the “OTEL_METRIC_EXPORT_INTERVAL” environment variable (in milliseconds).
Most users should use this method to attach an exporter. Advanced users
who need finer control over the export process can use
crate::metrics::PeriodicReaderBuilder
to configure a custom reader and attach it
using MeterProviderBuilder::with_reader()
.
Sourcepub fn build(self) -> SdkMeterProvider
pub fn build(self) -> SdkMeterProvider
Construct a new MeterProvider with this configuration.