Struct opentelemetry::trace::SpanBuilder [−][src]
pub struct SpanBuilder {}Show fields
pub parent_context: Context, pub trace_id: Option<TraceId>, pub span_id: Option<SpanId>, pub span_kind: Option<SpanKind>, pub name: Cow<'static, str>, pub start_time: Option<SystemTime>, pub end_time: Option<SystemTime>, pub attributes: Option<Vec<KeyValue>>, pub events: Option<Vec<Event>>, pub links: Option<Vec<Link>>, pub status_code: Option<StatusCode>, pub status_message: Option<Cow<'static, str>>, pub sampling_result: Option<SamplingResult>,
trace
only.SpanBuilder
allows span attributes to be configured before the span
has started.
use opentelemetry::{ global, trace::{TracerProvider, SpanBuilder, SpanKind, Tracer}, }; let tracer = global::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".into(), 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: Context
Parent Context
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: Cow<'static, str>
Span name
start_time: Option<SystemTime>
Span start time
end_time: Option<SystemTime>
Span end time
attributes: Option<Vec<KeyValue>>
Span attributes
events: Option<Vec<Event>>
Span events
links: Option<Vec<Link>>
Span Links
status_code: Option<StatusCode>
Span status code
status_message: Option<Cow<'static, str>>
Span status message
sampling_result: Option<SamplingResult>
Sampling result
Implementations
impl SpanBuilder
[src]
impl SpanBuilder
[src]SpanBuilder methods
pub fn from_name<T: Into<Cow<'static, str>>>(name: T) -> Self
[src]
pub fn from_name<T: Into<Cow<'static, str>>>(name: T) -> Self
[src]Create a new span builder from a span name
pub fn with_parent_context(self, parent_context: Context) -> Self
[src]
pub fn with_parent_context(self, parent_context: Context) -> Self
[src]Assign parent context
pub fn with_trace_id(self, trace_id: TraceId) -> Self
[src]
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]
pub fn with_span_id(self, span_id: SpanId) -> Self
[src]Assign span id
pub fn with_start_time<T: Into<SystemTime>>(self, start_time: T) -> Self
[src]
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]
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]
pub fn with_attributes(self, attributes: Vec<KeyValue>) -> Self
[src]Assign span attributes
pub fn with_events(self, events: Vec<Event>) -> Self
[src]
pub fn with_events(self, events: Vec<Event>) -> Self
[src]Assign events
pub fn with_links(self, links: Vec<Link>) -> Self
[src]
pub fn with_links(self, links: Vec<Link>) -> Self
[src]Assign links
pub fn with_status_code(self, code: StatusCode) -> Self
[src]
pub fn with_status_code(self, code: StatusCode) -> Self
[src]Assign status code
pub fn with_status_message<T: Into<Cow<'static, str>>>(self, message: T) -> Self
[src]
pub fn with_status_message<T: Into<Cow<'static, str>>>(self, message: T) -> Self
[src]Assign status message
pub fn with_sampling_result(self, sampling_result: SamplingResult) -> Self
[src]
pub fn with_sampling_result(self, sampling_result: SamplingResult) -> Self
[src]Assign sampling result
Trait Implementations
impl Clone for SpanBuilder
[src]
impl Clone for SpanBuilder
[src]fn clone(&self) -> SpanBuilder
[src]
fn clone(&self) -> SpanBuilder
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl Debug for SpanBuilder
[src]
impl Debug for SpanBuilder
[src]impl Default for SpanBuilder
[src]
impl Default for SpanBuilder
[src]fn default() -> SpanBuilder
[src]
fn default() -> SpanBuilder
[src]Returns the “default value” for a type. Read more
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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,