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_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 build(self) -> MetricResult<PrometheusExporter>
pub fn build(self) -> MetricResult<PrometheusExporter>
Creates a new PrometheusExporter from this configuration.