Skip to content

Commit b8ad2e6

Browse files
committed
middleware::log_request: Move custom metadata handling for Sentry into add_custom_metadata()
This allows us to add the metadata to issue reports as soon as possible, instead of only doing it in the `after()` method of the middleware.
1 parent 143f698 commit b8ad2e6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/middleware/log_request.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ pub fn add_custom_metadata<V: Display>(req: &mut dyn RequestExt, key: &'static s
8686
metadata.entries.push((key, value.to_string()));
8787
req.mut_extensions().insert(metadata);
8888
}
89+
90+
sentry::configure_scope(|scope| scope.set_extra(key, value.to_string().into()));
8991
}
9092

9193
fn report_to_sentry(req: &dyn RequestExt, res: &AfterResult, response_time: u64) {
@@ -119,12 +121,6 @@ fn report_to_sentry(req: &dyn RequestExt, res: &AfterResult, response_time: u64)
119121
}
120122

121123
scope.set_extra("Response time [ms]", response_time.into());
122-
123-
if let Some(metadata) = req.extensions().find::<CustomMetadata>() {
124-
for (key, value) in &metadata.entries {
125-
scope.set_extra(key, value.to_string().into());
126-
}
127-
}
128124
});
129125
}
130126

0 commit comments

Comments
 (0)