Repository: getsentry/sentry-rust (rust)

Issue:
Send trace origin
See https://github.com/getsentry/team-sdks/issues/14 and the [trace origin docs](https://develop.sentry.dev/sdk/telemetry/traces/trace-origin/). This functionality is currently missing from the Rust SDK and should be added.

Pull request:
feat: send trace origin
Close #681 

#skip-changelog

Patch:
diff --git a/sentry-actix/src/lib.rs b/sentry-actix/src/lib.rs
index 4a2de94..84a33b3 100644
--- a/sentry-actix/src/lib.rs
+++ b/sentry-actix/src/lib.rs
@@ -322,6 +322,7 @@ where
 
             let transaction = hub.start_transaction(ctx);
             transaction.set_request(sentry_req.clone());
+            transaction.set_data("origin", "auto.http.actix".into());
             Some(transaction)
         } else {
             None
diff --git a/sentry-opentelemetry/src/processor.rs b/sentry-opentelemetry/src/processor.rs
index 4c115cb..f883d16 100644
--- a/sentry-opentelemetry/src/processor.rs
+++ b/sentry-opentelemetry/src/processor.rs
@@ -170,8 +170,13 @@ impl SpanProcessor for SentrySpanProcessor {
         for attribute in data.attributes {
             sentry_span.set_data(attribute.key.as_str(), convert_value(attribute.value));
         }
+
         // TODO: read OTEL semantic convention span attributes and map them to the appropriate
         // Sentry span attributes/context values
+
+        if matches!(sentry_span, TransactionOrSpan::Transaction(_)) {
+            sentry_span.set_data("origin", "auto.otel".into())
+        }
         sentry_span.set_status(convert_span_status(&data.status));
         sentry_span.finish_with_timestamp(data.end_time);
     }
diff --git a/sentry-tower/src/http.rs b/sentry-tower/src/http.rs
index 95b46ad..92cc034 100644
--- a/sentry-tower/src/http.rs
+++ b/sentry-tower/src/http.rs
@@ -121,6 +121,7 @@ where
                     let transaction: sentry_core::TransactionOrSpan =
                         sentry_core::start_transaction(trx_ctx).into();
                     transaction.set_request(sentry_req.clone());
+                    transaction.set_data("origin", "auto.http.tower".into());
                     let parent_span = scope.get_span();
                     scope.set_span(Some(transaction.clone()));
                     *slf.transaction = Some((transaction, parent_span));
diff --git a/sentry-tracing/src/layer.rs b/sentry-tracing/src/layer.rs
index 582427e..efc4da5 100644
--- a/sentry-tracing/src/layer.rs
+++ b/sentry-tracing/src/layer.rs
@@ -313,7 +313,9 @@ where
             Some(parent) => parent.start_child(op, &description).into(),
             None => {
                 let ctx = sentry_core::TransactionContext::new(&description, op);
-                sentry_core::start_transaction(ctx).into()
+                let tx = sentry_core::start_transaction(ctx);
+                tx.set_data("origin", "auto.tracing".into());
+                tx.into()
             }
         };
         // Add the data from the original span to the sentry span.


Test patch:
diff --git a/sentry-tracing/tests/smoke.rs b/sentry-tracing/tests/smoke.rs
index 5bc0322..cb4f04e 100644
--- a/sentry-tracing/tests/smoke.rs
+++ b/sentry-tracing/tests/smoke.rs
@@ -33,7 +33,7 @@ fn should_instrument_function_with_event() {
         unexpected => panic!("Expected transaction, but got {unexpected:#?}"),
     };
     assert_eq!(transaction.tags.len(), 1);
-    assert_eq!(trace.data.len(), 2);
+    assert_eq!(trace.data.len(), 3);
 
     let tag = transaction
         .tags