From ba2734ab4d3cf051004ea4134b9b7d4bebfcd88a Mon Sep 17 00:00:00 2001 From: Clara Rull Date: Thu, 2 Nov 2023 06:48:28 -0700 Subject: [PATCH] Move ConnectionStats to mod Summary: Similar to D50838010, this struct was stubbed out in the OSS version, but moving it to `mod.rs` removed duplication later in the stack when a new implementation is introduced and the need for stubbing it out. Reviewed By: gustavoavena Differential Revision: D50841364 fbshipit-source-id: 01821db46e7aad75ec48bf41c14d458c79eeae9e --- shed/sql/common/mysql/mod.rs | 11 +++++++---- shed/sql/common/mysql/mysql_stub/mod.rs | 3 --- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/shed/sql/common/mysql/mod.rs b/shed/sql/common/mysql/mod.rs index 6100aead7..bb33c3636 100644 --- a/shed/sql/common/mysql/mod.rs +++ b/shed/sql/common/mysql/mod.rs @@ -19,8 +19,6 @@ pub use facebook::opt_try_from_rowfield; #[cfg(fbcode_build)] pub use facebook::Connection; #[cfg(fbcode_build)] -pub use facebook::ConnectionStats; -#[cfg(fbcode_build)] pub use facebook::MysqlError; #[cfg(fbcode_build)] pub use facebook::OptionalTryFromRowField; @@ -41,8 +39,6 @@ pub use mysql_stub::opt_try_from_rowfield; #[cfg(not(fbcode_build))] pub use mysql_stub::Connection; #[cfg(not(fbcode_build))] -pub use mysql_stub::ConnectionStats; -#[cfg(not(fbcode_build))] pub use mysql_stub::MysqlError; #[cfg(not(fbcode_build))] pub use mysql_stub::OptionalTryFromRowField; @@ -56,9 +52,16 @@ pub use mysql_stub::TransactionResult; pub use mysql_stub::TryFromRowField; #[cfg(not(fbcode_build))] pub use mysql_stub::ValueError; +use stats::prelude::*; use super::WriteResult as SqlWriteResult; +define_stats_struct! { + ConnectionStats("sql.mysql_ffi.{}", label: String), + get_connection_ms: histogram(100, 0, 5_000, Average, Count; P 50; P 95; P 99), + raw_query_ms: histogram(100, 0, 5_000, Average, Count; P 50; P 95; P 99), +} + /// A simple wrapper struct around a SQL string, just to add some type /// safety. #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/shed/sql/common/mysql/mysql_stub/mod.rs b/shed/sql/common/mysql/mysql_stub/mod.rs index 2939b7339..6a4853223 100644 --- a/shed/sql/common/mysql/mysql_stub/mod.rs +++ b/shed/sql/common/mysql/mysql_stub/mod.rs @@ -43,9 +43,6 @@ impl From for MysqlError { } } -/// ODS counters -pub struct ConnectionStats; - /// Connection object. #[derive(Clone)] pub struct Connection;