Skip to content

Commit 5c11709

Browse files
authored
fix: gate goblin logs before formatting (#3238)
### Description As evaluated in the context of #3237, in some configurations, just formatting the `goblin` logs can be costly enough to become a performance issue. This PR moves the logging gate for `goblin` into `enabled()` so that we discard its logs before we format them. ### Issues Raised as part of the fixes for getsentry/sentry#104738 ### Legal Boilerplate Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
1 parent 55609f2 commit 5c11709

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/utils/logging.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Logger {
5454

5555
impl log::Log for Logger {
5656
fn enabled(&self, metadata: &log::Metadata) -> bool {
57-
self.get_actual_level(metadata) <= max_level()
57+
!should_skip_log(metadata) && self.get_actual_level(metadata) <= max_level()
5858
}
5959

6060
fn log(&self, record: &log::Record) {
@@ -84,10 +84,6 @@ impl log::Log for Logger {
8484
.dim(),
8585
);
8686

87-
if should_skip_log(record) {
88-
return;
89-
}
90-
9187
if let Some(pb) = get_progress_bar() {
9288
pb.println(msg);
9389
} else {
@@ -98,9 +94,9 @@ impl log::Log for Logger {
9894
fn flush(&self) {}
9995
}
10096

101-
fn should_skip_log(record: &log::Record) -> bool {
102-
let level = record.metadata().level();
103-
let target = record.target();
97+
fn should_skip_log(metadata: &log::Metadata) -> bool {
98+
let level = metadata.level();
99+
let target = metadata.target();
104100

105101
// We want to filter everything that is non-error from `goblin` crate,
106102
// as `symbolicator` is responsible for making sure all warnings are handled correctly.

0 commit comments

Comments
 (0)