diff --git a/nexus/db-queries/src/transaction_retry.rs b/nexus/db-queries/src/transaction_retry.rs index 558bb574c97..03e0574f524 100644 --- a/nexus/db-queries/src/transaction_retry.rs +++ b/nexus/db-queries/src/transaction_retry.rs @@ -7,27 +7,15 @@ use async_bb8_diesel::AsyncConnection; use chrono::Utc; use diesel::result::Error as DieselError; -use oximeter::{types::Sample, Metric, MetricsError, Target}; +use oximeter::{types::Sample, MetricsError}; use rand::{thread_rng, Rng}; use slog::{info, warn, Logger}; use std::sync::{Arc, Mutex}; use std::time::Duration; -// Identifies "which" transaction is retrying -#[derive(Debug, Clone, Target)] -struct DatabaseTransaction { - name: String, -} - -// Identifies that a retry has occurred, and track how long -// the transaction took (either since starting, or since the last -// retry failure was recorded). -#[derive(Debug, Clone, Metric)] -struct RetryData { - #[datum] - latency: f64, - attempt: u32, -} +oximeter::use_timeseries!("database-transaction.toml"); +use database_transaction::DatabaseTransaction; +use database_transaction::RetryData; // Collects all transaction retry samples #[derive(Debug, Default, Clone)] @@ -156,7 +144,7 @@ impl RetryHelper { let _ = self.producer.append( &DatabaseTransaction { name: self.name.into() }, - &RetryData { latency, attempt }, + &RetryData { datum: latency, attempt }, ); // This backoff is not exponential, but I'm not sure we actually want diff --git a/oximeter/oximeter/schema/database-transaction.toml b/oximeter/oximeter/schema/database-transaction.toml new file mode 100644 index 00000000000..ce1477d6db9 --- /dev/null +++ b/oximeter/oximeter/schema/database-transaction.toml @@ -0,0 +1,26 @@ +format_version = 1 + +[target] +name = "database_transaction" +description = "A named transaction run in the control plane database" +authz_scope = "fleet" +versions = [ + { version = 1, fields = [ "name" ] } +] + +[[metrics]] +name = "retry_data" +description = "Information about a retried transaction" +units = "bytes" +datum_type = "f64" +versions = [ + { added_in = 1, fields = [ "attempt" ] } +] + +[fields.name] +type = "string" +description = "The name of the transaction" + +[fields.attempt] +type = "u32" +description = "The attempt at running the transaction"