Skip to content

Commit 2a00742

Browse files
authored
tower: Use tx.set_request() to set HTTP request metadata (#571)
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.
1 parent cf7d956 commit 2a00742

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

sentry-tower/src/http.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,21 @@ where
8686
let slf = self.project();
8787
if let Some((sentry_req, trx_ctx)) = slf.on_first_poll.take() {
8888
sentry_core::configure_scope(|scope| {
89-
scope.add_event_processor(move |mut event| {
90-
if event.request.is_none() {
91-
event.request = Some(sentry_req.clone());
92-
}
93-
Some(event)
94-
});
95-
9689
if let Some(trx_ctx) = trx_ctx {
9790
let transaction: sentry_core::TransactionOrSpan =
9891
sentry_core::start_transaction(trx_ctx).into();
92+
transaction.set_request(sentry_req.clone());
9993
let parent_span = scope.get_span();
10094
scope.set_span(Some(transaction.clone()));
10195
*slf.transaction = Some((transaction, parent_span));
10296
}
97+
98+
scope.add_event_processor(move |mut event| {
99+
if event.request.is_none() {
100+
event.request = Some(sentry_req.clone());
101+
}
102+
Some(event)
103+
});
103104
});
104105
}
105106
match slf.future.poll(cx) {

0 commit comments

Comments
 (0)