pub struct HttpTracerProviderBuilder<C: HttpClient + 'static = StdoutClient> { /* private fields */ }Expand description
Builder for configuring and initializing a TracerProvider.
This struct provides a fluent interface for configuring various aspects of the OpenTelemetry tracing setup, including the exporter type, propagators, and ID generators.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
use opentelemetry_sdk::trace::{TracerProvider, Tracer};
let tracer_provider: TracerProvider = HttpTracerProviderBuilder::default()
.with_stdout_client()
.enable_fmt_layer(true)
.with_tracer_name("my-service")
.with_default_text_map_propagator()
.with_default_id_generator()
.enable_global(true)
.build()?;Implementations§
Source§impl HttpTracerProviderBuilder
impl HttpTracerProviderBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new HttpTracerProviderBuilder with default settings.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::new();Sourcepub fn with_stdout_client(self) -> Self
pub fn with_stdout_client(self) -> Self
Configures the builder to use a stdout client for exporting traces.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().with_stdout_client();Sourcepub fn enable_fmt_layer(self, enabled: bool) -> Self
pub fn enable_fmt_layer(self, enabled: bool) -> Self
Enables or disables the fmt layer for logging.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().enable_fmt_layer(true);Sourcepub fn with_tracer_name(self, tracer_name: impl Into<Cow<'static, str>>) -> Self
pub fn with_tracer_name(self, tracer_name: impl Into<Cow<'static, str>>) -> Self
Sets the tracer name.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().with_tracer_name("my-service");Sourcepub fn with_text_map_propagator<P>(self, propagator: P) -> Self
pub fn with_text_map_propagator<P>(self, propagator: P) -> Self
Adds a custom text map propagator.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
use opentelemetry_sdk::propagation::TraceContextPropagator;
let builder = HttpTracerProviderBuilder::default()
.with_text_map_propagator(TraceContextPropagator::new());Sourcepub fn with_default_text_map_propagator(self) -> Self
pub fn with_default_text_map_propagator(self) -> Self
Adds the default text map propagator (TraceContextPropagator).
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().with_default_text_map_propagator();Sourcepub fn with_xray_text_map_propagator(self) -> Self
pub fn with_xray_text_map_propagator(self) -> Self
Adds the XRay text map propagator.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().with_xray_text_map_propagator();Sourcepub fn with_id_generator<I>(self, id_generator: I) -> Self
pub fn with_id_generator<I>(self, id_generator: I) -> Self
Sets a custom ID generator.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
use opentelemetry_sdk::trace::RandomIdGenerator;
let builder = HttpTracerProviderBuilder::default()
.with_id_generator(RandomIdGenerator::default());Sourcepub fn with_default_id_generator(self) -> Self
pub fn with_default_id_generator(self) -> Self
Sets the default ID generator (RandomIdGenerator).
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().with_default_id_generator();Sourcepub fn with_xray_id_generator(self) -> Self
pub fn with_xray_id_generator(self) -> Self
Adds the XRay ID generator.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().with_xray_id_generator();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 tracer provider.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().enable_global(true);Sourcepub fn with_simple_exporter(self) -> Self
pub fn with_simple_exporter(self) -> Self
Configures the builder to use a simple exporter.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().with_simple_exporter();Sourcepub fn with_batch_exporter(self) -> Self
pub fn with_batch_exporter(self) -> Self
Configures the builder to use a batch exporter.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let builder = HttpTracerProviderBuilder::default().with_batch_exporter();Sourcepub fn build(self) -> Result<TracerProvider, TraceError>
pub fn build(self) -> Result<TracerProvider, TraceError>
Builds the TracerProvider with the configured settings.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
use opentelemetry_sdk::trace::{TracerProvider, Tracer};
let tracer_provider: TracerProvider = HttpTracerProviderBuilder::default()
.with_stdout_client()
.enable_fmt_layer(true)
.with_tracer_name("my-service")
.with_default_text_map_propagator()
.with_default_id_generator()
.enable_global(true)
.build()?;Trait Implementations§
Source§impl<C: Debug + HttpClient + 'static> Debug for HttpTracerProviderBuilder<C>
impl<C: Debug + HttpClient + 'static> Debug for HttpTracerProviderBuilder<C>
Source§impl Default for HttpTracerProviderBuilder
impl Default for HttpTracerProviderBuilder
Provides a default implementation for HttpTracerProviderBuilder.
This implementation creates a new HttpTracerProviderBuilder with default settings
by calling the new() method.
§Examples
use lambda_otel_utils::HttpTracerProviderBuilder;
let default_builder = HttpTracerProviderBuilder::default();Auto Trait Implementations§
impl<C> Freeze for HttpTracerProviderBuilder<C>where
C: Freeze,
impl<C = StdoutClient> !RefUnwindSafe for HttpTracerProviderBuilder<C>
impl<C> Send for HttpTracerProviderBuilder<C>
impl<C> Sync for HttpTracerProviderBuilder<C>
impl<C> Unpin for HttpTracerProviderBuilder<C>where
C: Unpin,
impl<C = StdoutClient> !UnwindSafe for HttpTracerProviderBuilder<C>
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
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>
T in a tonic::Request