Skip to content

Commit 1c08ca8

Browse files
authored
ref(tracing): keep old span name as op instead of default (#905)
1 parent 75aff83 commit 1c08ca8

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
- ref(tracing): rework tracing to Sentry span name/op conversion ([#887](https://github.com/getsentry/sentry-rust/pull/887)) by @lcian
88
- The `tracing` integration now uses the tracing span name as the Sentry span name by default.
9-
- Before this change, the span name would be set based on the `tracing` span target (<module>::<function> when using the `tracing::instrument` macro).
10-
- The `tracing` integration now uses `default` as the default Sentry span op.
9+
- Before this change, the span name would be set based on the `tracing` span target (`<module>::<function>` when using the `tracing::instrument` macro).
10+
- The `tracing` integration now uses `<span target>::<span name>` as the default Sentry span op (i.e. `<module>::<function>` when using `tracing::instrument`).
1111
- Before this change, the span op would be set based on the `tracing` span name.
12+
- Read below to learn how to customize the span name and op.
1213
- When upgrading, please ensure to adapt any queries, metrics or dashboards to use the new span names/ops.
1314
- ref(tracing): use standard code attributes ([#899](https://github.com/getsentry/sentry-rust/pull/899)) by @lcian
1415
- Logs now carry the attributes `code.module.name`, `code.file.path` and `code.line.number` standardized in OTEL to surface the respective information, in contrast with the previously sent `tracing.module_path`, `tracing.file` and `tracing.line`.

sentry-tracing/src/layer.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,22 +303,23 @@ where
303303

304304
let (data, sentry_name, sentry_op, sentry_trace) = extract_span_data(attrs);
305305
let sentry_name = sentry_name.as_deref().unwrap_or_else(|| span.name());
306-
let sentry_op = sentry_op.as_deref().unwrap_or("default");
306+
let sentry_op =
307+
sentry_op.unwrap_or_else(|| format!("{}::{}", span.metadata().target(), span.name()));
307308

308309
let hub = sentry_core::Hub::current();
309310
let parent_sentry_span = hub.configure_scope(|scope| scope.get_span());
310311

311312
let mut sentry_span: sentry_core::TransactionOrSpan = match &parent_sentry_span {
312-
Some(parent) => parent.start_child(sentry_op, sentry_name).into(),
313+
Some(parent) => parent.start_child(&sentry_op, sentry_name).into(),
313314
None => {
314315
let ctx = if let Some(trace_header) = sentry_trace {
315316
sentry_core::TransactionContext::continue_from_headers(
316317
sentry_name,
317-
sentry_op,
318+
&sentry_op,
318319
[("sentry-trace", trace_header.as_str())],
319320
)
320321
} else {
321-
sentry_core::TransactionContext::new(sentry_name, sentry_op)
322+
sentry_core::TransactionContext::new(sentry_name, &sentry_op)
322323
};
323324

324325
let tx = sentry_core::start_transaction(ctx);

sentry-tracing/tests/smoke.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn should_instrument_function_with_event() {
2424
sentry::protocol::Context::Trace(trace) => trace,
2525
unexpected => panic!("Expected trace context but got {unexpected:?}"),
2626
};
27-
assert_eq!(trace.op.as_deref().unwrap(), "default");
27+
assert_eq!(trace.op.as_deref().unwrap(), "smoke::function_with_tags");
2828

2929
//Confirm transaction values
3030
let transaction = data.get(1).expect("should have 1 transaction");

0 commit comments

Comments
 (0)