Struct StartOptions

Source
pub struct StartOptions { /* private fields */ }
Expand description

Additional options that are passed to Tracer::span.

These options specify initial attributes of a span. All values are optional.

§Examples

extern crate opentracingrust;

use std::time::SystemTime;

use opentracingrust::StartOptions;
use opentracingrust::tracers::NoopTracer;


fn main() {
    let (tracer, _) = NoopTracer::new();
    let parent = tracer.span("parent");

    let now = SystemTime::now();
    let options = StartOptions::default()
        .child_of(parent.context().clone())
        .start_time(now);
    let span = tracer.span_with_options("test", options);
}

Implementations§

Source§

impl StartOptions

Source

pub fn child_of(self, parent: SpanContext) -> Self

Declares a ChildOf relationship for the Span to be.

Examples found in repository?
examples/0-quickstart.rs (line 78)
76fn fibonacci(n: u64, parent: SpanContext) -> u64 {
77    // To create a new span for this operation set the parent span.
78    let options = StartOptions::default().child_of(parent);
79    if n <= 2 {
80        // Since this is the base case we finish the span immediately.
81        let span = GlobalTracer::get().span_with_options("fibonacci base case", options);
82        span.finish().unwrap();
83        1
84    } else {
85        // Since this is the iterative case we recourse passing the new span's
86        // context as the new parent span.
87        let span = GlobalTracer::get().span_with_options("fibonacci iterative case", options);
88        let n1 = fibonacci(n - 1, span.context().clone());
89        let n2 = fibonacci(n - 2, span.context().clone());
90        // Once the recoursive operations terminate we can close the current span.
91        span.finish().unwrap();
92        n1 + n2
93    }
94}
Source

pub fn follows(self, parent: SpanContext) -> Self

Declares a FollowsFrom relationship for the Span to be.

Source

pub fn reference_span(self, reference: SpanReference) -> Self

Declares any of the SpanReferences for the Span to be.

Source

pub fn start_time(self, start_time: SystemTime) -> Self

Sets the start time for the operation.

Trait Implementations§

Source§

impl Default for StartOptions

Source§

fn default() -> StartOptions

Returns a default set of StartOptions.

By default the Span will:

  • Have no references, which will make it a root span.
  • Have have a start time of when Tracer::span is called.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V