From bfc54c6aa6cea15508f96cf4e71384ad1a923879 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Tue, 25 Apr 2023 14:35:21 +0200 Subject: [PATCH] tower: Use `tx.set_request()` to set HTTP request metadata Without this the transaction does not have any HTTP request metadata attached, because apparently the event processor is not running for performance traces. Note that I had to reorder the contents of the `configure_scope()` callback to be able to access `sentry_req` before it disappears into the `add_event_processor()` callback. --- sentry-tower/src/http.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sentry-tower/src/http.rs b/sentry-tower/src/http.rs index 82417d2b..63fd5599 100644 --- a/sentry-tower/src/http.rs +++ b/sentry-tower/src/http.rs @@ -86,20 +86,21 @@ where let slf = self.project(); if let Some((sentry_req, trx_ctx)) = slf.on_first_poll.take() { sentry_core::configure_scope(|scope| { - scope.add_event_processor(move |mut event| { - if event.request.is_none() { - event.request = Some(sentry_req.clone()); - } - Some(event) - }); - if let Some(trx_ctx) = trx_ctx { let transaction: sentry_core::TransactionOrSpan = sentry_core::start_transaction(trx_ctx).into(); + transaction.set_request(sentry_req.clone()); let parent_span = scope.get_span(); scope.set_span(Some(transaction.clone())); *slf.transaction = Some((transaction, parent_span)); } + + scope.add_event_processor(move |mut event| { + if event.request.is_none() { + event.request = Some(sentry_req); + } + Some(event) + }); }); } match slf.future.poll(cx) {