[−][src]Struct opentelemetry::api::trace::tracer::SpanBuilder
SpanBuilder
allows span attributes to be configured before the span
has started.
use opentelemetry::{ api::{Provider, SpanBuilder, SpanKind, Tracer}, global, }; let tracer = global::trace_provider().get_tracer("example-tracer"); // The builder can be used to create a span directly with the tracer let _span = tracer.build(SpanBuilder { name: "example-span-name".to_string(), span_kind: Some(SpanKind::Server), ..Default::default() }); // Or used with builder pattern let _span = tracer .span_builder("example-span-name") .with_kind(SpanKind::Server) .start(&tracer);
Fields
parent_context: Option<SpanContext>
Parent SpanContext
trace_id: Option<TraceId>
Trace id, useful for integrations with external tracing systems.
span_id: Option<SpanId>
Span id, useful for integrations with external tracing systems.
span_kind: Option<SpanKind>
Span kind
name: String
Span name
start_time: Option<SystemTime>
Span start time
end_time: Option<SystemTime>
Span end time
attributes: Option<Vec<KeyValue>>
Span attributes
message_events: Option<Vec<Event>>
Span Message events
links: Option<Vec<Link>>
Span Links
status_code: Option<StatusCode>
Span status code
status_message: Option<String>
Span status message
Methods
impl SpanBuilder
[src]
SpanBuilder methods
pub fn from_name(name: String) -> Self
[src]
Create a new span builder from a span name
pub fn with_parent(self, parent_context: SpanContext) -> Self
[src]
Assign parent context
pub fn with_trace_id(self, trace_id: TraceId) -> Self
[src]
Specify trace id to use if no parent context exists
pub fn with_span_id(self, span_id: SpanId) -> Self
[src]
Assign span id
pub fn with_kind(self, span_kind: SpanKind) -> Self
[src]
Assign span kind
pub fn with_start_time<T: Into<SystemTime>>(self, start_time: T) -> Self
[src]
Assign span start time
pub fn with_end_time<T: Into<SystemTime>>(self, end_time: T) -> Self
[src]
Assign span end time
pub fn with_attributes(self, attributes: Vec<KeyValue>) -> Self
[src]
Assign span attributes
pub fn with_message_events(self, message_events: Vec<Event>) -> Self
[src]
Assign message events
pub fn with_links(self, links: Vec<Link>) -> Self
[src]
Assign links
pub fn with_status_code(self, code: StatusCode) -> Self
[src]
Assign status code
pub fn with_status_message(self, message: String) -> Self
[src]
Assign status message
pub fn start<T: Tracer>(self, tracer: &T) -> T::Span
[src]
Builds a span with the given tracer from this configuration.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for SpanBuilder
impl Send for SpanBuilder
impl Sync for SpanBuilder
impl Unpin for SpanBuilder
impl UnwindSafe for SpanBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<F> Instrument for F
[src]
fn instrument<S: Span>(self, span: S) -> Instrumented<Self, S>
[src]
fn in_active_span<T: Tracer>(self, tracer: T) -> Instrumented<Self, T::Span>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,