Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update trace flags to match spec #565

Merged
merged 4 commits into from Jun 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion opentelemetry/src/trace/span_context.rs
Expand Up @@ -31,6 +31,7 @@ pub struct TraceFlags(u8);
impl TraceFlags {
/// Trace flags with the `sampled` flag set to `1`.
///
/// Spans that are not sampled will be ignored by most tracing tools.
/// See the `sampled` section of the [W3C TraceContext specification] for details.
///
/// [W3C TraceContext specification]: https://www.w3.org/TR/trace-context/#sampled-flag
Expand Down Expand Up @@ -371,6 +372,9 @@ impl FromStr for TraceState {
}

/// Immutable portion of a `Span` which can be serialized and propagated.
///
/// Spans that do not have the `sampled` flag set in their [`TraceFlags`] will
/// be ignored by most tracing tools.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks!

#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq)]
pub struct SpanContext {
Expand Down Expand Up @@ -437,7 +441,9 @@ impl SpanContext {
self.is_remote
}

/// Returns true if the `SpanContext` is sampled.
/// Returns `true` if the `sampled` trace flag is set.
///
/// Spans that are not sampled will be ignored by most tracing tools.
pub fn is_sampled(&self) -> bool {
self.trace_flags.is_sampled()
}
Expand Down