pub struct ExporterBuilder { /* private fields */ }
Expand description
PrometheusExporter configuration options
Implementations§
source§impl ExporterBuilder
impl ExporterBuilder
sourcepub fn without_units(self) -> Self
pub fn without_units(self) -> Self
Disables exporter’s addition of unit suffixes to metric names.
By default, metric names include a unit suffix to follow Prometheus naming
conventions. For example, the counter metric request.duration
, with unit
ms
would become request_duration_milliseconds_total
.
With this option set, the name would instead be request_duration_total
.
sourcepub fn without_counter_suffixes(self) -> Self
pub fn without_counter_suffixes(self) -> Self
Disables exporter’s addition _total
suffixes on counters.
By default, metric names include a _total
suffix to follow Prometheus
naming conventions. For example, the counter metric happy.people
would
become happy_people_total
. With this option set, the name would instead be
happy_people
.
sourcepub fn without_target_info(self) -> Self
pub fn without_target_info(self) -> Self
Configures the exporter to not export the resource target_info
metric.
If not specified, the exporter will create a target_info
metric containing
the metrics’ Resource attributes.
sourcepub fn without_scope_info(self) -> Self
pub fn without_scope_info(self) -> Self
Configures the exporter to not export the otel_scope_info
metric.
If not specified, the exporter will create a otel_scope_info
metric
containing the metrics’ Instrumentation Scope, and also add labels about
Instrumentation Scope to all metric points.
sourcepub fn with_namespace(self, namespace: impl Into<String>) -> Self
pub fn with_namespace(self, namespace: impl Into<String>) -> Self
Configures the exporter to prefix metrics with the given namespace.
Metrics such as target_info
and otel_scope_info
are not prefixed since
these have special behavior based on their name.
sourcepub fn with_registry(self, registry: Registry) -> Self
pub fn with_registry(self, registry: Registry) -> Self
Configures which prometheus::Registry the exporter will use.
If no registry is specified, the prometheus default is used.
sourcepub fn with_aggregation_selector(
self,
agg: impl AggregationSelector + 'static,
) -> Self
pub fn with_aggregation_selector( self, agg: impl AggregationSelector + 'static, ) -> Self
Configure the AggregationSelector the exporter will use.
If no selector is provided, the DefaultAggregationSelector is used.
sourcepub fn with_resource_selector(
self,
resource_selector: impl Into<ResourceSelector>,
) -> Self
pub fn with_resource_selector( self, resource_selector: impl Into<ResourceSelector>, ) -> Self
Configures whether to export resource as attributes with every metric.
Note that this is orthogonal to the target_info
metric, which can be disabled using without_target_info
.
If you called without_target_info
and with_resource_selector
with ResourceSelector::None
, resource will not be exported at all.
sourcepub fn with_producer(self, producer: impl MetricProducer + 'static) -> Self
pub fn with_producer(self, producer: impl MetricProducer + 'static) -> Self
Registers an external MetricProducer with this reader.
The producer is used as a source of aggregated metric data which is incorporated into metrics collected from the SDK.
sourcepub fn build(self) -> Result<PrometheusExporter>
pub fn build(self) -> Result<PrometheusExporter>
Creates a new PrometheusExporter from this configuration.