Skip to content

Commit 2749cd1

Browse files
committed
chore: cleaner set tag code
1 parent 111e573 commit 2749cd1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/wasm/src/sentry_gauge.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,14 @@ where
256256
}));
257257

258258
let config = Config::get_config();
259-
scope.set_tag("developer", if let Some(config) = &config { config.addon.developer.clone() } else { "unknown".into() });
260-
scope.set_tag("product", if let Some(config) = &config { config.addon.product.clone() } else { "unknown".into() });
259+
scope.set_tag(
260+
"developer",
261+
config.as_ref().map_or("unknown", |c| &c.addon.developer),
262+
);
263+
scope.set_tag(
264+
"product",
265+
config.as_ref().map_or("unknown", |c| &c.addon.product),
266+
);
261267
});
262268

263269
// Drain any pending reports. We need to structure it like this as opposed to just a top level `let Ok(state) = ...`` due to the fact we should not be holding a MutexGuard across an await point
@@ -328,8 +334,6 @@ where
328334
Ok(())
329335
}
330336

331-
332-
333337
/// A convenience macro to handle the gauge entrypoint and sentry wrapping around a struct that implements `SentryGauge`
334338
///
335339
/// Example: `sentry_gauge!(MyGauge, my_gauge_name)`

0 commit comments

Comments
 (0)