Skip to content

Commit b435d76

Browse files
authored
Merge 9dc857f into 4b886a8
2 parents 4b886a8 + 9dc857f commit b435d76

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

sentry-core/src/performance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl Transaction {
571571
.contexts
572572
.insert("trace".into(), inner.context.clone().into());
573573

574-
// TODO: apply the scope to the transaction, whatever that means
574+
Hub::current().with_current_scope(|scope| scope.apply_to_transaction(&mut transaction));
575575
let opts = client.options();
576576
transaction.release = opts.release.clone();
577577
transaction.environment = opts.environment.clone();

sentry-core/src/scope/real.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt;
44
use std::sync::{Arc, Mutex, PoisonError, RwLock};
55

66
use crate::performance::TransactionOrSpan;
7-
use crate::protocol::{Attachment, Breadcrumb, Context, Event, Level, User, Value};
7+
use crate::protocol::{Attachment, Breadcrumb, Context, Event, Level, Transaction, User, Value};
88
use crate::session::Session;
99
use crate::Client;
1010

@@ -302,6 +302,21 @@ impl Scope {
302302
Some(event)
303303
}
304304

305+
/// Applies the contained scoped data to fill a transaction.
306+
pub fn apply_to_transaction(&self, transaction: &mut Transaction<'static>) {
307+
transaction
308+
.extra
309+
.extend(self.extra.iter().map(|(k, v)| (k.to_owned(), v.to_owned())));
310+
transaction
311+
.tags
312+
.extend(self.tags.iter().map(|(k, v)| (k.to_owned(), v.to_owned())));
313+
transaction.contexts.extend(
314+
self.contexts
315+
.iter()
316+
.map(|(k, v)| (k.to_owned(), v.to_owned())),
317+
);
318+
}
319+
305320
/// Set the given [`TransactionOrSpan`] as the active span for this scope.
306321
pub fn set_span(&mut self, span: Option<TransactionOrSpan>) {
307322
self.span = Arc::new(span);

0 commit comments

Comments
 (0)