diff --git a/Cargo.lock b/Cargo.lock index 26becff36..f59c1a034 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3064,7 +3064,7 @@ dependencies = [ "redis", "serde", "tempfile", - "thiserror 2.0.18", + "thiserror 2.0.20", "tokio", "tokio-shared-rt", "tracing", diff --git a/nexus-common/src/db/graph/instrumented.rs b/nexus-common/src/db/graph/instrumented.rs index c3e409df1..8e2125cf9 100644 --- a/nexus-common/src/db/graph/instrumented.rs +++ b/nexus-common/src/db/graph/instrumented.rs @@ -11,7 +11,7 @@ use std::time::{Duration, Instant}; use tracing::warn; use super::ops::{Graph, GraphOps}; -use super::query::Query; +use super::query::{Query, TelemetryValue}; use crate::utils::ms; /// The OpenTelemetry meter name used by all Neo4j graph metrics. @@ -33,15 +33,38 @@ struct GraphMetrics { execute_duration: Histogram, /// Number of rows returned by a query. rows: Histogram, + /// Total queries (error-rate denominator). Same sites as `duration`. + requests: Counter, /// Incremented on every failed `execute()` or `run()` call. errors: Counter, /// Incremented when a query's total duration exceeds the slow-query threshold. slow: Counter, } -/// Returns the single-element attribute slice used for all Neo4j metric recordings. -fn query_attrs(label: Option<&'static str>) -> [KeyValue; 1] { - [KeyValue::new("query", label.unwrap_or("unknown"))] +/// Builds the shared metric, span, and log attributes: `query=