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

Update trace flags to match spec #565

merged 4 commits into from Jun 7, 2021

Conversation

jtescher
Copy link
Member

@jtescher jtescher commented Jun 7, 2021

Remove all trace flags except sampled as that is the only supported flag in the current trace spec. Removes SpanContext::is_deferred and SpanContext::is_debug as they are also no longer supported.

Resolves #559

@jtescher jtescher requested a review from a team as a code owner June 7, 2021 02:03
Remove all trace flags except `sampled` as that is the only supported
flag in the current trace spec. Removes `SpanContext::is_deferred` and
`SpanContex::is_debug` as they are also no longer supported.
Copy link
Contributor

@TommyCpp TommyCpp left a comment

Choose a reason for hiding this comment

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

Looks good! Just a small nit: I wonder if use !TraceFlags::SAMPLED in tests will be better than TraceFlags::default() as readers don't need to figure out what's the default of TraceFlags?

@codecov
Copy link

codecov bot commented Jun 7, 2021

Codecov Report

Merging #565 (8fababf) into main (635f10e) will increase coverage by 0.0%.
The diff coverage is 94.2%.

❗ Current head 8fababf differs from pull request most recent head c47dcfb. Consider uploading reports for the commit c47dcfb to get more accurate results
Impacted file tree graph

@@          Coverage Diff          @@
##            main    #565   +/-   ##
=====================================
  Coverage   54.6%   54.7%           
=====================================
  Files         98      98           
  Lines       8550    8576   +26     
=====================================
+ Hits        4674    4694   +20     
- Misses      3876    3882    +6     
Impacted Files Coverage Δ
opentelemetry-jaeger/src/exporter/mod.rs 47.8% <0.0%> (ø)
opentelemetry/src/global/trace.rs 17.0% <ø> (ø)
opentelemetry/src/trace/mod.rs 50.0% <ø> (ø)
opentelemetry/src/util.rs 27.7% <ø> (ø)
opentelemetry/src/sdk/trace/tracer.rs 85.9% <80.0%> (+0.1%) ⬆️
opentelemetry/src/trace/span_context.rs 91.7% <81.2%> (-1.8%) ⬇️
opentelemetry-aws/src/lib.rs 93.3% <100.0%> (ø)
opentelemetry-datadog/src/exporter/model/mod.rs 64.1% <100.0%> (+0.5%) ⬆️
opentelemetry-datadog/src/lib.rs 92.4% <100.0%> (ø)
opentelemetry-jaeger/src/lib.rs 94.1% <100.0%> (+0.1%) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 635f10e...c47dcfb. Read the comment docs.

@jtescher
Copy link
Member Author

jtescher commented Jun 7, 2021

@TommyCpp yeah little confusing. As TraceFlags is a bitset !TraceFlags::SAMPLED is the same as !0x01 which is 0xfe rather than 0x00. So what you would want would maybe be more like TraceFlags::default() & !TraceFlags::SAMPLED, but that's not super readable either. Looked at the other impls and it doesn't seem like others have an unsampled constant in the public API.

@joshtriplett
Copy link

This seems like an improvement. Would you consider adding documentation on SpanContext and on TraceFlags::SAMPLED that mentions that some tracing tools will completely ignore spans that don't have the sampled flag set?

@@ -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!

@jtescher
Copy link
Member Author

jtescher commented Jun 7, 2021

@TommyCpp I can think more about test clarity and do a follow up PR if a better solution emerges there.

@jtescher jtescher merged commit dc7d81f into main Jun 7, 2021
@jtescher jtescher deleted the trace-flags branch June 7, 2021 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please document effect of trace_flags in SpanContext (must set sampled to process trace)
4 participants