Add PrometheusMetrics
This commit is contained in:
29
Cargo.lock
generated
29
Cargo.lock
generated
@@ -326,6 +326,20 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "actix-web-prom"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec994b7dd52e686b9ae8f63bc485e6027fb44b936ed09bdf648495b9966c36ce"
|
||||||
|
dependencies = [
|
||||||
|
"actix-http",
|
||||||
|
"actix-service",
|
||||||
|
"actix-web",
|
||||||
|
"futures",
|
||||||
|
"pin-project 1.0.6",
|
||||||
|
"prometheus",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix_derive"
|
name = "actix_derive"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@@ -1136,6 +1150,7 @@ dependencies = [
|
|||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
|
"actix-web-prom",
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"chrono",
|
"chrono",
|
||||||
"diesel",
|
"diesel",
|
||||||
@@ -1728,6 +1743,20 @@ dependencies = [
|
|||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prometheus"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c8425533e7122f0c3cc7a37e6244b16ad3a2cc32ae7ac6276e2a75da0d9c200d"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"fnv",
|
||||||
|
"lazy_static",
|
||||||
|
"parking_lot",
|
||||||
|
"regex",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-error"
|
name = "quick-error"
|
||||||
version = "1.2.3"
|
version = "1.2.3"
|
||||||
|
|||||||
@@ -32,3 +32,4 @@ notify = "4.0"
|
|||||||
path-absolutize = "3.0.6"
|
path-absolutize = "3.0.6"
|
||||||
log="0.4"
|
log="0.4"
|
||||||
env_logger="0.8"
|
env_logger="0.8"
|
||||||
|
actix-web-prom = "0.5.1"
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ extern crate diesel;
|
|||||||
extern crate rayon;
|
extern crate rayon;
|
||||||
|
|
||||||
use crate::auth::login;
|
use crate::auth::login;
|
||||||
|
use actix_web_prom::PrometheusMetrics;
|
||||||
use database::{DbError, DbErrorKind, FavoriteDao, SqliteFavoriteDao, SqliteUserDao, UserDao};
|
use database::{DbError, DbErrorKind, FavoriteDao, SqliteFavoriteDao, SqliteUserDao, UserDao};
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use std::io::prelude::*;
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{collections::HashMap, io::prelude::*};
|
||||||
use std::{env, fs::File};
|
use std::{env, fs::File};
|
||||||
|
|
||||||
use actix::prelude::*;
|
use actix::prelude::*;
|
||||||
@@ -404,6 +405,9 @@ fn main() -> std::io::Result<()> {
|
|||||||
stream_manager: Arc::new(act),
|
stream_manager: Arc::new(act),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let labels = HashMap::new();
|
||||||
|
let prometheus = PrometheusMetrics::new("", Some("/metrics"), Some(labels));
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
let user_dao = SqliteUserDao::new();
|
let user_dao = SqliteUserDao::new();
|
||||||
let favorites_dao = SqliteFavoriteDao::new();
|
let favorites_dao = SqliteFavoriteDao::new();
|
||||||
@@ -422,6 +426,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
.app_data(app_data.clone())
|
.app_data(app_data.clone())
|
||||||
.data::<Box<dyn UserDao>>(Box::new(user_dao))
|
.data::<Box<dyn UserDao>>(Box::new(user_dao))
|
||||||
.data::<Box<dyn FavoriteDao>>(Box::new(favorites_dao))
|
.data::<Box<dyn FavoriteDao>>(Box::new(favorites_dao))
|
||||||
|
.wrap(prometheus.clone())
|
||||||
})
|
})
|
||||||
.bind(dotenv::var("BIND_URL").unwrap())?
|
.bind(dotenv::var("BIND_URL").unwrap())?
|
||||||
.bind("localhost:8088")?
|
.bind("localhost:8088")?
|
||||||
|
|||||||
Reference in New Issue
Block a user