File tree Expand file tree Collapse file tree 7 files changed +18
-8
lines changed
sentry-types/src/protocol Expand file tree Collapse file tree 7 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -322,7 +322,7 @@ where
322
322
323
323
let transaction = hub. start_transaction ( ctx) ;
324
324
transaction. set_request ( sentry_req. clone ( ) ) ;
325
- transaction. set_data ( "origin" , " auto.http.actix". into ( ) ) ;
325
+ transaction. set_origin ( " auto.http.actix") ;
326
326
Some ( transaction)
327
327
} else {
328
328
None
Original file line number Diff line number Diff line change @@ -819,6 +819,12 @@ impl Transaction {
819
819
}
820
820
}
821
821
822
+ /// Sets the origin for this transaction, indicating what created it.
823
+ pub fn set_origin ( & self , origin : & str ) {
824
+ let mut inner = self . inner . lock ( ) . unwrap ( ) ;
825
+ inner. context . origin = Some ( origin. to_owned ( ) ) ;
826
+ }
827
+
822
828
/// Returns the headers needed for distributed tracing.
823
829
/// Use [`crate::Scope::iter_trace_propagation_headers`] to obtain the active
824
830
/// trace's distributed tracing headers.
Original file line number Diff line number Diff line change @@ -174,8 +174,8 @@ impl SpanProcessor for SentrySpanProcessor {
174
174
// TODO: read OTEL semantic convention span attributes and map them to the appropriate
175
175
// Sentry span attributes/context values
176
176
177
- if matches ! ( sentry_span , TransactionOrSpan :: Transaction ( _ ) ) {
178
- sentry_span . set_data ( "origin" , " auto.otel". into ( ) )
177
+ if let TransactionOrSpan :: Transaction ( transaction ) = & sentry_span {
178
+ transaction . set_origin ( " auto.otel") ;
179
179
}
180
180
sentry_span. set_status ( convert_span_status ( & data. status ) ) ;
181
181
sentry_span. finish_with_timestamp ( data. end_time ) ;
Original file line number Diff line number Diff line change @@ -118,10 +118,10 @@ where
118
118
if let Some ( ( sentry_req, trx_ctx) ) = slf. on_first_poll . take ( ) {
119
119
sentry_core:: configure_scope ( |scope| {
120
120
if let Some ( trx_ctx) = trx_ctx {
121
- let transaction: sentry_core:: TransactionOrSpan =
122
- sentry_core:: start_transaction ( trx_ctx) . into ( ) ;
121
+ let transaction = sentry_core:: start_transaction ( trx_ctx) ;
122
+ transaction. set_origin ( "auto.http.tower" ) ;
123
+ let transaction: sentry_core:: TransactionOrSpan = transaction. into ( ) ;
123
124
transaction. set_request ( sentry_req. clone ( ) ) ;
124
- transaction. set_data ( "origin" , "auto.http.tower" . into ( ) ) ;
125
125
let parent_span = scope. get_span ( ) ;
126
126
scope. set_span ( Some ( transaction. clone ( ) ) ) ;
127
127
* slf. transaction = Some ( ( transaction, parent_span) ) ;
Original file line number Diff line number Diff line change @@ -322,7 +322,7 @@ where
322
322
} ;
323
323
324
324
let tx = sentry_core:: start_transaction ( ctx) ;
325
- tx. set_data ( "origin" , " auto.tracing". into ( ) ) ;
325
+ tx. set_origin ( " auto.tracing") ;
326
326
tx. into ( )
327
327
}
328
328
} ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ fn should_instrument_function_with_event() {
34
34
} ;
35
35
assert_eq ! ( transaction. name, Some ( "function_with_tags" . into( ) ) ) ;
36
36
assert_eq ! ( transaction. tags. len( ) , 1 ) ;
37
- assert_eq ! ( trace. data. len( ) , 7 ) ;
37
+ assert_eq ! ( trace. data. len( ) , 6 ) ;
38
38
39
39
let tag = transaction
40
40
. tags
Original file line number Diff line number Diff line change @@ -1504,6 +1504,10 @@ pub struct TraceContext {
1504
1504
/// Describes the status of the span (e.g. `ok`, `cancelled`, etc.)
1505
1505
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
1506
1506
pub status : Option < SpanStatus > ,
1507
+ /// Describes what created the transaction. See the [develop
1508
+ /// docs](https://develop.sentry.dev/sdk/telemetry/traces/trace-origin/) for more information.
1509
+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
1510
+ pub origin : Option < String > ,
1507
1511
/// Optional data attributes to be associated with the transaction.
1508
1512
#[ serde( default , skip_serializing_if = "Map::is_empty" ) ]
1509
1513
pub data : Map < String , Value > ,
You can’t perform that action at this time.
0 commit comments