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

Ensure compliance with b3 propagator spec #314

Closed
jtescher opened this issue Oct 28, 2020 · 1 comment · Fixed by #319
Closed

Ensure compliance with b3 propagator spec #314

jtescher opened this issue Oct 28, 2020 · 1 comment · Fixed by #319

Comments

@jtescher
Copy link
Member

See the clarification of the spec here open-telemetry/opentelemetry-specification#1045

@TommyCpp
Copy link
Contributor

TommyCpp commented Oct 29, 2020

I think we almost dodge all the bullets on this one. 😂 The only difference with spec is

MUST attempt to extract B3 encoded using single and multi-header
formats. The single-header variant takes precedence over
the multi-header version.

When extract we will follow users' choice on encoding. But if user select SingleAndMultiHeader, we will try single first. Wonder if we want to change it to always try single format first and fall back to multiple version when single format is not present or invalid.

The rest of the change should already be covered. See details below

MUST preserve a debug trace flag, if received, and propagate
it with subsequent requests. Additionally, an OpenTelemetry implementation
MUST set the sampled trace flag when the debug flag is set.

We set the sampled and debug flag in SpanContext,

"1" => Ok(TRACE_FLAG_DEBUG | TRACE_FLAG_SAMPLED), // debug implies sampled

MUST NOT reuse X-B3-SpanId as the id for the server-side span.

I think we use the result of extraction as remote span context, so we will always generate new span for operation in the application

cx.with_remote_span_context(span_context)

MUST NOT propagate X-B3-ParentSpanId as OpenTelemetry does not support
reusing the same id for both sides of a request.

We don't inject this header

if self.inject_encoding.support(&B3Encoding::MultipleHeader)
|| self.inject_encoding.support(&B3Encoding::UnSpecified)
{
// if inject_encoding is Unspecified, default to use MultipleHeader
injector.set(
B3_TRACE_ID_HEADER,
format!("{:032x}", span_context.trace_id().to_u128()),
);
injector.set(
B3_SPAN_ID_HEADER,
format!("{:016x}", span_context.span_id().to_u64()),
);
if span_context.is_debug() {
injector.set(B3_DEBUG_FLAG_HEADER, "1".to_string());
} else if !span_context.is_deferred() {
let sampled = if span_context.is_sampled() { "1" } else { "0" };
injector.set(B3_SAMPLED_HEADER, sampled.to_string());
}
}

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 a pull request may close this issue.

2 participants