-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change moves the storage and management of active spans from the current `SpanStack` implementation to the new `Context` api, as well as updating the propagation APIs to inject and extract contexts to remain compatible with the tracers. This has some breaking API changes to the way tracing is currently done, most notable is that the `Tracer`'s `start` method no longer requires an optional parent span context as that can now be provided by the current context. The previous tracing api was: ```rust // extract let remote_span_context = propagator.extract(&carrier); // start let parent = tracer.start("parent", Some(remote_context)); tracer.mark_span_as_active(&parent); // nest (note: `Some(parent.get_context())` and `None` had the same effect here) let child = tracer.start("child", None); tracer.mark_span_as_active(&child) // inject propagator.inject(child.get_context(), &mut carrier); // Marking as inactive was required and error-prone trace.mark_span_as_inactive(&child); trace.mark_span_as_inactive(&parent); ``` And the new API is: ```rust // extract let _attach = propagator.extract(&carrier).attach(); // start let parent = tracer.start("parent"); let _parent_active = tracer.mark_span_as_active(parent); // start let child = tracer.start("child"); let _child_active = tracer.mark_span_as_active(parent); // inject propagator.inject(&mut carrier) ``` Additional changes to facilitate the switch: * `tracer.with_span` now accepts a span for naming consistency and managing the active state of a more complex span (likely produced by a builder), and the previous functionality that accepts a `&str` has been renamed to `in_span`, both of which now yield a context to the provided closure. * The `Instrument` trait has been renamed to `FutureExt` to avoid clashing with metric instruments, and accepts contexts. * `TracerGenerics` methods have been folded in to the `Tracer` trait so the trait is no longer needed 🎉 . * A `TraceContextExt` trait provides methods for working with trace data in a context. Most notably `context.span()` returns a `&dyn api::Span` reference, and `Context::current_with_span(span)` creates a clone of the current context with the span added. * Span's managing their own active state is no longer needed 🎉. * Span's `get_context` method has been renamed to `span_context` to avoid the ambiguity.
- Loading branch information
Showing
38 changed files
with
778 additions
and
601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.