feat: prefer jaeger trace context (#2311)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/24376/head
Raphael Taylor-Davies 2021-08-16 21:34:26 +01:00 committed by GitHub
parent c012e996ab
commit a20b452cf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 18 deletions

View File

@ -154,10 +154,10 @@ enum ContextCodec {
impl ContextCodec {
fn detect(headers: &HeaderMap) -> Option<Self> {
if headers.contains_key(B3_TRACE_ID_HEADER) {
Some(B3)
} else if headers.contains_key(JAEGER_TRACE_HEADER) {
if headers.contains_key(JAEGER_TRACE_HEADER) {
Some(Jaeger)
} else if headers.contains_key(B3_TRACE_ID_HEADER) {
Some(B3)
} else {
None
}
@ -177,11 +177,7 @@ fn decode_b3(
// Debug implies an accept decision
true => true,
false => decoded_header(headers, B3_SAMPLED_HEADER)?
.map(|value| {
// TEMPORARY (#2297)
info!(sampled=%value, "traced request");
value == "1" || value == "true"
})
.map(|value| value == "1" || value == "true")
.unwrap_or(false),
};
@ -189,16 +185,6 @@ fn decode_b3(
return Ok(None);
}
let ctx = SpanContext {
trace_id: required_header(headers, B3_TRACE_ID_HEADER)?,
parent_span_id: parsed_header(headers, B3_PARENT_SPAN_ID_HEADER)?,
span_id: required_header(headers, B3_SPAN_ID_HEADER)?,
collector: Some(Arc::clone(collector)),
};
// TEMPORARY (#2297)
info!(?ctx, "tracing request");
Ok(Some(SpanContext {
trace_id: required_header(headers, B3_TRACE_ID_HEADER)?,
parent_span_id: parsed_header(headers, B3_PARENT_SPAN_ID_HEADER)?,
@ -219,6 +205,9 @@ impl FromStr for JaegerCtx {
fn from_str(s: &str) -> Result<Self, Self::Err> {
use itertools::Itertools;
// TEMPORARY (#2297)
info!("traced request {}", s);
let (trace_id, span_id, parent_span_id, flags) = s
.split(':')
.collect_tuple()