Struct tracing_opentelemetry::OpenTelemetryLayer
source · [−]pub struct OpenTelemetryLayer<S, T> { /* private fields */ }Expand description
An OpenTelemetry propagation layer for use in a project that uses tracing.
Implementations
impl<S, T> OpenTelemetryLayer<S, T> where
S: Subscriber + for<'span> LookupSpan<'span>,
T: Tracer + PreSampledTracer + 'static,
impl<S, T> OpenTelemetryLayer<S, T> where
S: Subscriber + for<'span> LookupSpan<'span>,
T: Tracer + PreSampledTracer + 'static,
Set the Tracer that this layer will use to produce and track
OpenTelemetry Spans.
Examples
use tracing_opentelemetry::OpenTelemetryLayer;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::Registry;
// Create a jaeger exporter pipeline for a `trace_demo` service.
let tracer = opentelemetry_jaeger::new_pipeline()
.with_service_name("trace_demo")
.install_simple()
.expect("Error initializing Jaeger exporter");
// Create a layer with the configured tracer
let otel_layer = OpenTelemetryLayer::new(tracer);
// Use the tracing subscriber `Registry`, or any other subscriber
// that impls `LookupSpan`
let subscriber = Registry::default().with(otel_layer);pub fn with_tracer<Tracer>(
self,
tracer: Tracer
) -> OpenTelemetryLayer<S, Tracer> where
Tracer: Tracer + PreSampledTracer + 'static,
pub fn with_tracer<Tracer>(
self,
tracer: Tracer
) -> OpenTelemetryLayer<S, Tracer> where
Tracer: Tracer + PreSampledTracer + 'static,
Set the Tracer that this layer will use to produce and track
OpenTelemetry Spans.
Examples
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::Registry;
// Create a jaeger exporter pipeline for a `trace_demo` service.
let tracer = opentelemetry_jaeger::new_pipeline()
.with_service_name("trace_demo")
.install_simple()
.expect("Error initializing Jaeger exporter");
// Create a layer with the configured tracer
let otel_layer = tracing_opentelemetry::layer().with_tracer(tracer);
// Use the tracing subscriber `Registry`, or any other subscriber
// that impls `LookupSpan`
let subscriber = Registry::default().with(otel_layer);Sets whether or not spans metadata should include the busy time (total time for which it was entered), and idle time (total time the span existed but was not entered).
Trait Implementations
impl<S> Default for OpenTelemetryLayer<S, NoopTracer> where
S: Subscriber + for<'span> LookupSpan<'span>,
impl<S> Default for OpenTelemetryLayer<S, NoopTracer> where
S: Subscriber + for<'span> LookupSpan<'span>,
impl<S, T> Layer<S> for OpenTelemetryLayer<S, T> where
S: Subscriber + for<'span> LookupSpan<'span>,
T: Tracer + PreSampledTracer + 'static,
impl<S, T> Layer<S> for OpenTelemetryLayer<S, T> where
S: Subscriber + for<'span> LookupSpan<'span>,
T: Tracer + PreSampledTracer + 'static,
Creates an OpenTelemetry Span for the corresponding tracing Span.
Record OpenTelemetry attributes for the given values.
Notifies this layer that a span with the given ID was entered.
Notifies this layer that the span with the given ID was exited.
Notifies this layer that a span with the ID span recorded that it
follows from the span with the ID follows. Read more
Performs late initialization when attaching a Layer to a
Subscriber. Read more
Registers a new callsite with this layer, returning whether or not
the layer is interested in being notified about the callsite, similarly
to Subscriber::register_callsite. Read more
Returns true if this layer is interested in a span or event with the
given metadata in the current Context, similarly to
Subscriber::enabled. Read more
Notifies this layer that a span ID has been cloned, and that the subscriber returned a different ID. Read more
Composes this layer around the given Layer, returning a Layered
struct implementing Layer. Read more
Composes this Layer with the given Subscriber, returning a
Layered struct that implements Subscriber. Read more
Auto Trait Implementations
impl<S, T> RefUnwindSafe for OpenTelemetryLayer<S, T> where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<S, T> Send for OpenTelemetryLayer<S, T> where
S: Send,
T: Send,
impl<S, T> Sync for OpenTelemetryLayer<S, T> where
S: Sync,
T: Sync,
impl<S, T> Unpin for OpenTelemetryLayer<S, T> where
S: Unpin,
T: Unpin,
impl<S, T> UnwindSafe for OpenTelemetryLayer<S, T> where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
