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_sdk::error::Error> {
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 enable_global(self, set_global: bool) -> Self
pub fn enable_global(self, set_global: bool) -> Self
Enables or disables global installation of the meter provider.
§Examples
use lambda_otel_utils::HttpMeterProviderBuilder;
let builder = HttpMeterProviderBuilder::default().enable_global(true);
Sourcepub fn build(self) -> Result<SdkMeterProvider, OTelSdkError>
pub fn build(self) -> Result<SdkMeterProvider, OTelSdkError>
Builds the MeterProvider
with the configured settings.
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