pub struct StrandsTelemetry {
pub resource: OtelResource,
/* private fields */
}Expand description
OpenTelemetry configuration and setup for Strands applications.
Automatically initializes a tracer provider with text map propagators. Trace exporters (console, OTLP) can be set up individually using dedicated methods that support method chaining for convenient configuration.
§Examples
Quick setup with method chaining:
StrandsTelemetry::new().setup_console_exporter().setup_otlp_exporter();Using a custom tracer provider:
StrandsTelemetry::with_tracer_provider(my_provider).setup_console_exporter();Step-by-step configuration:
let telemetry = StrandsTelemetry::new();
telemetry.setup_console_exporter();
telemetry.setup_otlp_exporter();To setup global meter provider:
telemetry.setup_meter(true, true); // enable_console, enable_otlpFields§
§resource: OtelResourceImplementations§
Source§impl StrandsTelemetry
impl StrandsTelemetry
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new StrandsTelemetry instance.
This initializes a new tracer provider and sets it as the global provider.
Sourcepub fn with_tracer_provider(tracer_provider: SdkTracerProvider) -> Self
pub fn with_tracer_provider(tracer_provider: SdkTracerProvider) -> Self
Create a new StrandsTelemetry instance with a pre-configured tracer provider.
Sourcepub fn setup_console_exporter(self) -> Self
pub fn setup_console_exporter(self) -> Self
Set up console exporter for traces (no-op when feature not enabled).
Sourcepub fn setup_otlp_exporter(self) -> Self
pub fn setup_otlp_exporter(self) -> Self
Set up OTLP exporter for traces (no-op when feature not enabled).
Sourcepub fn setup_meter(self, _enable_console: bool, _enable_otlp: bool) -> Self
pub fn setup_meter(self, _enable_console: bool, _enable_otlp: bool) -> Self
Set up the meter provider for metrics (no-op when features not enabled).
Sourcepub fn is_console_enabled(&self) -> bool
pub fn is_console_enabled(&self) -> bool
Check if console exporter is enabled.
Sourcepub fn is_otlp_enabled(&self) -> bool
pub fn is_otlp_enabled(&self) -> bool
Check if OTLP exporter is enabled.
Sourcepub fn is_meter_enabled(&self) -> bool
pub fn is_meter_enabled(&self) -> bool
Check if meter is enabled.
Sourcepub fn resource(&self) -> &OtelResource
pub fn resource(&self) -> &OtelResource
Get the resource.
Sourcepub fn tracer_provider(&self) -> Option<&SdkTracerProvider>
pub fn tracer_provider(&self) -> Option<&SdkTracerProvider>
Get the tracer provider.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StrandsTelemetry
impl !RefUnwindSafe for StrandsTelemetry
impl Send for StrandsTelemetry
impl Sync for StrandsTelemetry
impl Unpin for StrandsTelemetry
impl !UnwindSafe for StrandsTelemetry
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more