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
impl StartOptions
Sourcepub fn child_of(self, parent: SpanContext) -> Self
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}
Sourcepub fn follows(self, parent: SpanContext) -> Self
pub fn follows(self, parent: SpanContext) -> Self
Declares a FollowsFrom
relationship for the Span
to be.
Sourcepub fn reference_span(self, reference: SpanReference) -> Self
pub fn reference_span(self, reference: SpanReference) -> Self
Declares any of the SpanReference
s for the Span
to be.
Sourcepub fn start_time(self, start_time: SystemTime) -> Self
pub fn start_time(self, start_time: SystemTime) -> Self
Sets the start time for the operation.
Trait Implementations§
Source§impl Default for StartOptions
impl Default for StartOptions
Source§fn default() -> StartOptions
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§
impl Freeze for StartOptions
impl !RefUnwindSafe for StartOptions
impl Send for StartOptions
impl !Sync for StartOptions
impl Unpin for StartOptions
impl !UnwindSafe for StartOptions
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
Mutably borrows from an owned value. Read more