diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-10 16:09:50 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-01-10 16:09:50 -0800 |
commit | 60d39b2f9923bf1b9d659f2f4dad223ec565466a (patch) | |
tree | b992730fe230bec74744db4babd3f1eff83f180b /rust/src/server.rs | |
parent | 5a31f1181e9a86aa91e95be87ac386731ce219cd (diff) | |
download | fatcat-60d39b2f9923bf1b9d659f2f4dad223ec565466a.tar.gz fatcat-60d39b2f9923bf1b9d659f2f4dad223ec565466a.zip |
crude metrics integration (only a handful for now)
Diffstat (limited to 'rust/src/server.rs')
-rw-r--r-- | rust/src/server.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/rust/src/server.rs b/rust/src/server.rs index 6b389a97..66b215fc 100644 --- a/rust/src/server.rs +++ b/rust/src/server.rs @@ -8,6 +8,7 @@ use diesel::pg::PgConnection; use diesel::r2d2::ConnectionManager; use dotenv::dotenv; use std::env; +use cadence::{StatsdClient, NopMetricSink}; #[cfg(feature = "postgres")] embed_migrations!("../migrations/"); @@ -32,6 +33,7 @@ pub fn database_worker_pool() -> Result<ConnectionPool> { pub struct Server { pub db_pool: ConnectionPool, pub auth_confectionary: AuthConfectionary, + pub metrics: StatsdClient, } /// Instantiate a new API server with a pooled database connection @@ -39,13 +41,15 @@ pub fn create_server() -> Result<Server> { dotenv().ok(); let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set"); let manager = ConnectionManager::<PgConnection>::new(database_url); - let pool = diesel::r2d2::Pool::builder() + let db_pool = diesel::r2d2::Pool::builder() .build(manager) .expect("Failed to create database pool."); - let confectionary = env_confectionary()?; + let auth_confectionary = env_confectionary()?; + let metrics = StatsdClient::from_sink("blackhole", NopMetricSink); Ok(Server { - db_pool: pool, - auth_confectionary: confectionary, + db_pool, + auth_confectionary, + metrics, }) } |