Skip to content

Commit

Permalink
its on the scope after all
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Jan 3, 2022
1 parent b064da4 commit 7ae46b6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
7 changes: 0 additions & 7 deletions sentry-core/src/performance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ impl Hub {
pub fn start_transaction(&self, ctx: TransactionContext) -> Transaction {
Transaction::new(self.client(), ctx)
}

// oh well, its on the hub, not on the scope -_-
pub fn get_span(&self) -> Option<TransactionOrSpan> {
with_client_impl! {{
self.with_current_scope(|scope| scope.span.as_ref().as_ref().cloned())
}}
}
}

// "Context" Types:
Expand Down
4 changes: 4 additions & 0 deletions sentry-core/src/scope/real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ impl Scope {
self.span = Arc::new(span);
}

pub fn get_span(&self) -> Option<TransactionOrSpan> {
self.span.as_ref().clone()
}

pub(crate) fn update_session_from_event(&self, event: &Event<'static>) {
if let Some(session) = self.session.lock().unwrap().as_mut() {
session.update_from_event(event);
Expand Down
2 changes: 1 addition & 1 deletion sentry/examples/performance-demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {

thread::sleep(Duration::from_millis(50));

let headers = match sentry::Hub::current().get_span() {
let headers = match sentry::configure_scope(|scope| scope.get_span()) {
Some(span) => vec![span.iter_headers().next().unwrap()],
None => vec![],
};
Expand Down

0 comments on commit 7ae46b6

Please sign in to comment.