pub struct HttpMeterProviderBuilder<C: HttpClient + 'static = StdoutClient> { /* private fields */ }Expand description
Builder for configuring and initializing a MeterProvider.
This struct provides a fluent interface for configuring various aspects of the OpenTelemetry metrics setup, including the exporter configuration and meter names.
§Examples
use lambda_otel_utils::HttpMeterProviderBuilder;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), opentelemetry::metrics::MetricsError> {
let meter_provider = HttpMeterProviderBuilder::default()
.with_stdout_client()
.with_meter_name("my-service")
.with_export_interval(Duration::from_secs(60))
.build()?;
Ok(())
}Implementations§
Source§impl HttpMeterProviderBuilder
impl HttpMeterProviderBuilder
Sourcepub fn with_stdout_client(self) -> Self
pub fn with_stdout_client(self) -> Self
Configures the builder to use a stdout client for exporting metrics.
Sourcepub fn with_meter_name(self, meter_name: &'static str) -> Self
pub fn with_meter_name(self, meter_name: &'static str) -> Self
Sourcepub fn with_export_interval(self, interval: Duration) -> Self
pub fn with_export_interval(self, interval: Duration) -> Self
Sets the export interval for periodic metric collection.
Sourcepub fn with_export_timeout(self, timeout: Duration) -> Self
pub fn with_export_timeout(self, timeout: Duration) -> Self
Sets the export timeout for metric collection.
Sourcepub fn build(self) -> MetricsResult<SdkMeterProvider>
pub fn build(self) -> MetricsResult<SdkMeterProvider>
Builds the MeterProvider with the configured settings.
Sourcepub fn get_meter(self, provider: &SdkMeterProvider) -> Meter
pub fn get_meter(self, provider: &SdkMeterProvider) -> Meter
Gets a meter from the provider with the configured name.
Trait Implementations§
Source§impl<C: Debug + HttpClient + 'static> Debug for HttpMeterProviderBuilder<C>
impl<C: Debug + HttpClient + 'static> Debug for HttpMeterProviderBuilder<C>
Auto Trait Implementations§
impl<C> Freeze for HttpMeterProviderBuilder<C>where
C: Freeze,
impl<C> RefUnwindSafe for HttpMeterProviderBuilder<C>where
C: RefUnwindSafe,
impl<C> Send for HttpMeterProviderBuilder<C>
impl<C> Sync for HttpMeterProviderBuilder<C>
impl<C> Unpin for HttpMeterProviderBuilder<C>where
C: Unpin,
impl<C> UnwindSafe for HttpMeterProviderBuilder<C>where
C: UnwindSafe,
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
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::Request