pub struct PrometheusExporter { /* private fields */ }Available on crate features
observability and prometheus only.Expand description
A handle that renders and serves the metrics collected by the paired
PrometheusReader. Cheap to clone.
Implementations§
Source§impl PrometheusExporter
impl PrometheusExporter
Sourcepub fn build(
config: PrometheusConfig,
) -> Result<(PrometheusExporter, PrometheusExporter), Error>
pub fn build( config: PrometheusConfig, ) -> Result<(PrometheusExporter, PrometheusExporter), Error>
Builds the reader (register it with an SdkMeterProvider) and the
handle that renders it.
Sourcepub fn config(&self) -> &PrometheusConfig
pub fn config(&self) -> &PrometheusConfig
The configuration this exporter was built with.
Sourcepub fn render(&self) -> Result<String, Error>
pub fn render(&self) -> Result<String, Error>
Collects and encodes the current metrics in the Prometheus text
format (0.0.4). Synchronous and CPU-bound; prefer render_async
from async code.
Sourcepub fn router<S>(&self) -> Router<S>
pub fn router<S>(&self) -> Router<S>
A router answering GET <path>. It carries no Kerniq middleware, so
merging it after the application’s middleware has been applied keeps
scrapes out of the HTTP metrics.
Sourcepub async fn serve(
&self,
listener: TcpListener,
shutdown: impl Future<Output = ()> + Send + 'static,
) -> Result<(), Error>
pub async fn serve( &self, listener: TcpListener, shutdown: impl Future<Output = ()> + Send + 'static, ) -> Result<(), Error>
Serves the metrics endpoint on listener until shutdown completes.
Used for PrometheusConfig::listen; usable directly for custom
setups.
Trait Implementations§
Source§impl Clone for PrometheusExporter
impl Clone for PrometheusExporter
Source§fn clone(&self) -> PrometheusExporter
fn clone(&self) -> PrometheusExporter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for PrometheusExporter
impl !UnwindSafe for PrometheusExporter
impl Forget for PrometheusExporter
impl Freeze for PrometheusExporter
impl Send for PrometheusExporter
impl Sync for PrometheusExporter
impl Unpin for PrometheusExporter
impl UnsafeUnpin for PrometheusExporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
Available on crate features
compression-br or compression-deflate or compression-gzip or compression-zstd only.Compresses response bodies. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Available on crate feature
trace only.High level tracing that classifies responses using gRPC headers. Read more
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Available on crate feature
request-id only.Add request id header and extension. Read more
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Available on crate feature
request-id only.Add request id header and extension, using
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Available on crate feature
request-id only.Propgate request ids from requests to responses. Read more
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
Available on crate feature
request-id only.Propgate request ids from requests to responses, using
x-request-id as the header name. Read more