Clean up TelemetryGuard and inline sentry_client_options
Removed manual Drop impl from TelemetryGuard — Rust default field
drop order (provider then sentry) is already correct. Added comment
explaining why field order matters. Re-added sentry_client_options
as a shared helper. Marked TelemetryGuard fields #[allow(dead_code)]
since they are only used during drop.
Assisted-by: Owl Alpha via pi
diff --git a/quire-core/src/telemetry.rs b/quire-core/src/telemetry.rs
index 209c0ef..e2f9b2c 100644
--- a/quire-core/src/telemetry.rs
+++ b/quire-core/src/telemetry.rs
@@ -204,25 +204,22 @@ pub enum FmtMode {
pub fn sentry_client_options(release: &'static str) -> sentry::ClientOptions {
sentry::ClientOptions {
release: Some(release.into()),
- before_send: Some(Arc::new(before_send)),
+ before_send: Some(std::sync::Arc::new(before_send)),
..Default::default()
}
}
/// Returned by `init_telemetry`; shuts down both tracing and Sentry on drop.
+///
+/// Field order matters: `provider` is dropped first (flushing OTEL spans
+/// through the Sentry client), then `sentry` is dropped (flushing events
+/// to the Sentry server).
+#[allow(dead_code)]
pub struct TelemetryGuard {
- #[allow(dead_code)]
provider: opentelemetry_sdk::trace::SdkTracerProvider,
sentry: Option<sentry::ClientInitGuard>,
}
-impl Drop for TelemetryGuard {
- fn drop(&mut self) {
- // Drop tracing first (flushes OTEL spans to Sentry), then Sentry.
- self.sentry.take();
- }
-}
-
/// Initialize both tracing and Sentry.
///
/// Sets up the global tracing subscriber (OTEL + stderr fmt) and, if a