Skip to content

Commit bec93d2

Browse files
authored
refactor(core): remove support for traceparent (#807)
1 parent 7dd572b commit bec93d2

File tree

2 files changed

+19
-61
lines changed

2 files changed

+19
-61
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sentry-core/src/performance.rs

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,8 @@ impl TransactionContext {
170170

171171
/// Creates a new Transaction Context based on the distributed tracing `headers`.
172172
///
173-
/// The `headers` in particular need to include either the `sentry-trace` or W3C
174-
/// `traceparent` header, which is used to associate the transaction with a distributed
175-
/// trace. If both are present, `sentry-trace` takes precedence.
173+
/// The `headers` in particular need to include the `sentry-trace` header,
174+
/// which is used to associate the transaction with a distributed trace.
176175
#[must_use = "this must be used with `start_transaction`"]
177176
pub fn continue_from_headers<'a, I: IntoIterator<Item = (&'a str, &'a str)>>(
178177
name: &str,
@@ -1142,8 +1141,8 @@ impl Iterator for TraceHeadersIter {
11421141
}
11431142
}
11441143

1145-
/// A container for distributed tracing metadata that can be extracted from e.g. HTTP headers such as
1146-
/// `sentry-trace` and `traceparent`.
1144+
/// A container for distributed tracing metadata that can be extracted from e.g. the `sentry-trace`
1145+
/// HTTP header.
11471146
#[derive(Debug, PartialEq)]
11481147
pub struct SentryTrace(protocol::TraceId, protocol::SpanId, Option<bool>);
11491148

@@ -1173,25 +1172,8 @@ fn parse_sentry_trace(header: &str) -> Option<SentryTrace> {
11731172
Some(SentryTrace(trace_id, parent_span_id, parent_sampled))
11741173
}
11751174

1176-
/// Parses a W3C traceparent header.
1177-
/// Reference: <https://w3c.github.io/trace-context/#traceparent-header-field-values>
1178-
fn parse_w3c_traceparent(header: &str) -> Option<SentryTrace> {
1179-
let header = header.trim();
1180-
let mut parts = header.splitn(4, '-');
1181-
1182-
let _version = parts.next()?;
1183-
let trace_id = parts.next()?.parse().ok()?;
1184-
let parent_span_id = parts.next()?.parse().ok()?;
1185-
let parent_sampled = parts
1186-
.next()
1187-
.and_then(|sampled| u8::from_str_radix(sampled, 16).ok())
1188-
.map(|flag| flag & 1 != 0);
1189-
1190-
Some(SentryTrace(trace_id, parent_span_id, parent_sampled))
1191-
}
1192-
11931175
/// Extracts distributed tracing metadata from headers (or, generally, key-value pairs),
1194-
/// considering the values for both `sentry-trace` (prioritized) and `traceparent`.
1176+
/// considering the values for `sentry-trace`.
11951177
pub fn parse_headers<'a, I: IntoIterator<Item = (&'a str, &'a str)>>(
11961178
headers: I,
11971179
) -> Option<SentryTrace> {
@@ -1201,10 +1183,6 @@ pub fn parse_headers<'a, I: IntoIterator<Item = (&'a str, &'a str)>>(
12011183
trace = parse_sentry_trace(v);
12021184
break;
12031185
}
1204-
1205-
if k.eq_ignore_ascii_case("traceparent") {
1206-
trace = parse_w3c_traceparent(v);
1207-
}
12081186
}
12091187
trace
12101188
}
@@ -1241,26 +1219,6 @@ mod tests {
12411219
assert_eq!(parsed, Some(trace));
12421220
}
12431221

1244-
#[test]
1245-
fn parses_traceparent() {
1246-
let trace_id = protocol::TraceId::from_str("4bf92f3577b34da6a3ce929d0e0e4736").unwrap();
1247-
let parent_trace_id = protocol::SpanId::from_str("00f067aa0ba902b7").unwrap();
1248-
1249-
let trace =
1250-
parse_w3c_traceparent("00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01");
1251-
assert_eq!(
1252-
trace,
1253-
Some(SentryTrace(trace_id, parent_trace_id, Some(true)))
1254-
);
1255-
1256-
let trace =
1257-
parse_w3c_traceparent("00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00");
1258-
assert_eq!(
1259-
trace,
1260-
Some(SentryTrace(trace_id, parent_trace_id, Some(false)))
1261-
);
1262-
}
1263-
12641222
#[test]
12651223
fn disabled_forwards_trace_id() {
12661224
let headers = [(

0 commit comments

Comments
 (0)