From 25806c74cb740d92ba214ff1699499d2fb724d6e Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Fri, 20 May 2022 02:22:48 -0700 Subject: [PATCH] feat: Expose tracing fields as span data (#445) Signed-off-by: Jess Frazelle --- sentry-tracing/src/layer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sentry-tracing/src/layer.rs b/sentry-tracing/src/layer.rs index 7cb1113c..b2926c52 100644 --- a/sentry-tracing/src/layer.rs +++ b/sentry-tracing/src/layer.rs @@ -164,7 +164,7 @@ where return; } - let (description, _data) = extract_span_data(attrs); + let (description, data) = extract_span_data(attrs); let op = span.name(); // Spans don't always have a description, this ensures our data is not empty, @@ -186,6 +186,12 @@ where sentry_core::start_transaction(ctx).into() } }; + // Add the data from the original span to the sentry span. + // This comes from typically the `fields` in `tracing::instrument`. + for (key, value) in data { + sentry_span.set_data(&key, value); + } + sentry_core::configure_scope(|scope| scope.set_span(Some(sentry_span.clone()))); let mut extensions = span.extensions_mut();