Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

- ref(tracing): rework tracing to Sentry span name/op conversion ([#887](https://github.com/getsentry/sentry-rust/pull/887)) by @lcian
- The `tracing` integration now uses the tracing span name as the Sentry span name by default.
- Before this change, the span name would be set based on the `tracing` span target (<module>::<function> when using the `tracing::instrument` macro).
- The `tracing` integration now uses `default` as the default Sentry span op.
- Before this change, the span name would be set based on the `tracing` span target (`<module>::<function>` when using the `tracing::instrument` macro).
- The `tracing` integration now uses `<span target>::<span name>` as the default Sentry span op (i.e. `<module>::<function>` when using `tracing::instrument`).
- Before this change, the span op would be set based on the `tracing` span name.
- Read below to learn how to customize the span name and op.
- When upgrading, please ensure to adapt any queries, metrics or dashboards to use the new span names/ops.
- ref(tracing): use standard code attributes ([#899](https://github.com/getsentry/sentry-rust/pull/899)) by @lcian
- 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`.
Expand Down
9 changes: 5 additions & 4 deletions sentry-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,22 +303,23 @@ where

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

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

let mut sentry_span: sentry_core::TransactionOrSpan = match &parent_sentry_span {
Some(parent) => parent.start_child(sentry_op, sentry_name).into(),
Some(parent) => parent.start_child(&sentry_op, sentry_name).into(),
None => {
let ctx = if let Some(trace_header) = sentry_trace {
sentry_core::TransactionContext::continue_from_headers(
sentry_name,
sentry_op,
&sentry_op,
[("sentry-trace", trace_header.as_str())],
)
} else {
sentry_core::TransactionContext::new(sentry_name, sentry_op)
sentry_core::TransactionContext::new(sentry_name, &sentry_op)
};

let tx = sentry_core::start_transaction(ctx);
Expand Down
2 changes: 1 addition & 1 deletion sentry-tracing/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn should_instrument_function_with_event() {
sentry::protocol::Context::Trace(trace) => trace,
unexpected => panic!("Expected trace context but got {unexpected:?}"),
};
assert_eq!(trace.op.as_deref().unwrap(), "default");
assert_eq!(trace.op.as_deref().unwrap(), "smoke::function_with_tags");

//Confirm transaction values
let transaction = data.get(1).expect("should have 1 transaction");
Expand Down
Loading