Move trait imports to file scope; rename SentryContext to TelemetryContext
https://claude.ai/code/session_01Tbgz29e8A9KS4Bh94skkFX
diff --git a/quire-ci/src/main.rs b/quire-ci/src/main.rs
index 68d2cd1..89017e6 100644
--- a/quire-ci/src/main.rs
+++ b/quire-ci/src/main.rs
@@ -239,14 +239,14 @@ impl RunClient {
///
/// One-shot: the server marks the bootstrap as fetched after the first
/// successful call and returns 410 on any subsequent call.
- fn fetch_bootstrap(&self) -> Result<(PathBuf, RunMeta, SentryContext)> {
+ fn fetch_bootstrap(&self) -> Result<(PathBuf, RunMeta, TelemetryContext)> {
let bootstrap: Bootstrap =
(|| -> reqwest::Result<_> { self.get("bootstrap")?.error_for_status()?.json() })()
.into_diagnostic()?;
Ok((
bootstrap.git_dir,
bootstrap.meta,
- SentryContext {
+ TelemetryContext {
traceparent: bootstrap.traceparent,
repo: Some(bootstrap.repo),
run_id: Some(bootstrap.run_id),
@@ -341,7 +341,7 @@ fn main() -> Result<()> {
r#ref: git_ref,
pushed_at: jiff::Timestamp::now(),
};
- (git_dir, meta, SentryContext::default())
+ (git_dir, meta, TelemetryContext::default())
} else {
client.fetch_bootstrap()?
};
@@ -385,7 +385,7 @@ fn main() -> Result<()> {
/// from [`RunMeta`]: `meta` carries push facts the pipeline needs,
/// these tag observability only.
#[derive(Default)]
-struct SentryContext {
+struct TelemetryContext {
traceparent: Option<String>,
repo: Option<String>,
run_id: Option<String>,
@@ -397,7 +397,7 @@ struct SentryContext {
/// trace context come from the bootstrap handoff and are attached only
/// when present (absent for local runs); the trace id links both
/// sides' events onto the same trace.
-fn init_sentry(dsn: &str, meta: &RunMeta, ctx: &SentryContext) -> sentry::ClientInitGuard {
+fn init_sentry(dsn: &str, meta: &RunMeta, ctx: &TelemetryContext) -> sentry::ClientInitGuard {
let guard = sentry::init((dsn, telemetry::sentry_client_options(VERSION)));
sentry::configure_scope(|scope| {
scope.set_tag("service", "quire-ci");
diff --git a/quire-core/src/telemetry.rs b/quire-core/src/telemetry.rs
index 5b77c0b..ecac6aa 100644
--- a/quire-core/src/telemetry.rs
+++ b/quire-core/src/telemetry.rs
@@ -4,6 +4,9 @@ use std::io::IsTerminal;
use std::sync::Arc;
use miette::IntoDiagnostic;
+use opentelemetry::propagation::TextMapPropagator as _;
+use opentelemetry::trace::TracerProvider as _;
+use tracing_opentelemetry::OpenTelemetrySpanExt as _;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::Layer;
use tracing_subscriber::layer::SubscriberExt;
@@ -201,8 +204,6 @@ impl Drop for TracingGuard {
/// Extract the W3C traceparent from a tracing span's OTEL context.
/// Returns None when the span has no valid OTEL context (e.g. OTEL not initialised).
pub fn traceparent_from_span(span: &tracing::Span) -> Option<String> {
- use opentelemetry::propagation::TextMapPropagator as _;
- use tracing_opentelemetry::OpenTelemetrySpanExt as _;
let propagator = opentelemetry_sdk::propagation::TraceContextPropagator::new();
let cx = span.context();
let mut carrier = std::collections::HashMap::new();
@@ -213,7 +214,6 @@ pub fn traceparent_from_span(span: &tracing::Span) -> Option<String> {
/// Decode a W3C traceparent string into an OTEL context suitable for
/// passing to [`tracing_opentelemetry::OpenTelemetrySpanExt::set_parent`].
pub fn context_from_traceparent(traceparent: &str) -> opentelemetry::Context {
- use opentelemetry::propagation::TextMapPropagator as _;
let propagator = opentelemetry_sdk::propagation::TraceContextPropagator::new();
let mut carrier = std::collections::HashMap::new();
carrier.insert("traceparent".to_string(), traceparent.to_string());
@@ -245,7 +245,6 @@ pub fn init_tracing(miette_layer: MietteLayer, fmt_mode: FmtMode) -> miette::Res
}
};
- use opentelemetry::trace::TracerProvider as _;
let provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
.with_span_processor(sentry_opentelemetry::SentrySpanProcessor::new())
.build();