mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 05:00:06 +01:00
clippy & rustfmt fixed
This commit is contained in:
parent
4bee0565e8
commit
25fecf9360
@ -7,7 +7,6 @@ pub mod task;
|
|||||||
pub mod extractors;
|
pub mod extractors;
|
||||||
pub mod option;
|
pub mod option;
|
||||||
pub mod routes;
|
pub mod routes;
|
||||||
pub mod metrics;
|
|
||||||
|
|
||||||
use std::sync::{atomic::AtomicBool, Arc};
|
use std::sync::{atomic::AtomicBool, Arc};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@ -145,19 +144,21 @@ pub fn dashboard(config: &mut web::ServiceConfig, _enable_frontend: bool) {
|
|||||||
macro_rules! create_app {
|
macro_rules! create_app {
|
||||||
($data:expr, $auth:expr, $enable_frontend:expr, $opt:expr, $analytics:expr) => {{
|
($data:expr, $auth:expr, $enable_frontend:expr, $opt:expr, $analytics:expr) => {{
|
||||||
use actix_cors::Cors;
|
use actix_cors::Cors;
|
||||||
|
use actix_web::dev::Service;
|
||||||
use actix_web::middleware::TrailingSlash;
|
use actix_web::middleware::TrailingSlash;
|
||||||
use actix_web::App;
|
use actix_web::App;
|
||||||
use actix_web::dev::Service;
|
|
||||||
use actix_web::{middleware, web};
|
use actix_web::{middleware, web};
|
||||||
use meilisearch_http::error::MeilisearchHttpError;
|
use meilisearch_http::error::MeilisearchHttpError;
|
||||||
|
use meilisearch_http::metrics;
|
||||||
use meilisearch_http::routes;
|
use meilisearch_http::routes;
|
||||||
use meilisearch_http::{configure_data, dashboard};
|
use meilisearch_http::{configure_data, dashboard};
|
||||||
use meilisearch_types::error::ResponseError;
|
use meilisearch_types::error::ResponseError;
|
||||||
use meilisearch_http::metrics;
|
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use prometheus::{opts, register_histogram_vec, register_int_counter_vec, register_int_gauge};
|
use prometheus::{
|
||||||
use prometheus::{HistogramVec, IntCounterVec, IntGauge, HistogramTimer};
|
opts, register_histogram_vec, register_int_counter_vec, register_int_gauge,
|
||||||
|
};
|
||||||
|
use prometheus::{HistogramTimer, HistogramVec, IntCounterVec, IntGauge};
|
||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.configure(|s| configure_data(s, $data.clone(), $auth.clone(), &$opt, $analytics))
|
.configure(|s| configure_data(s, $data.clone(), $auth.clone(), &$opt, $analytics))
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use prometheus::{opts, register_histogram_vec, register_int_counter_vec, register_int_gauge, register_int_gauge_vec};
|
use prometheus::{
|
||||||
|
opts, register_histogram_vec, register_int_counter_vec, register_int_gauge,
|
||||||
|
register_int_gauge_vec,
|
||||||
|
};
|
||||||
use prometheus::{HistogramVec, IntCounterVec, IntGauge, IntGaugeVec};
|
use prometheus::{HistogramVec, IntCounterVec, IntGauge, IntGaugeVec};
|
||||||
|
|
||||||
const HTTP_RESPONSE_TIME_CUSTOM_BUCKETS: &[f64; 14] = &[
|
const HTTP_RESPONSE_TIME_CUSTOM_BUCKETS: &[f64; 14] = &[
|
||||||
@ -13,23 +16,21 @@ lazy_static! {
|
|||||||
&["method", "path"]
|
&["method", "path"]
|
||||||
)
|
)
|
||||||
.expect("Can't create a metric");
|
.expect("Can't create a metric");
|
||||||
|
pub static ref MEILISEARCH_DB_SIZE: IntGauge = register_int_gauge!(opts!(
|
||||||
pub static ref MEILISEARCH_DB_SIZE: IntGauge = register_int_gauge!(
|
"meilisearch_database_size",
|
||||||
opts!("meilisearch_database_size", "MeiliSearch Stats DbSize")
|
"MeiliSearch Stats DbSize"
|
||||||
)
|
))
|
||||||
.expect("Can't create a metric");
|
.expect("Can't create a metric");
|
||||||
|
pub static ref MEILISEARCH_INDEX_COUNT: IntGauge = register_int_gauge!(opts!(
|
||||||
pub static ref MEILISEARCH_INDEX_COUNT: IntGauge = register_int_gauge!(
|
"meilisearch_total_index",
|
||||||
opts!("meilisearch_total_index", "MeiliSearch Stats Index Count")
|
"MeiliSearch Stats Index Count"
|
||||||
)
|
))
|
||||||
.expect("Can't create a metric");
|
.expect("Can't create a metric");
|
||||||
|
|
||||||
pub static ref MEILISEARCH_DOCS_COUNT: IntGaugeVec = register_int_gauge_vec!(
|
pub static ref MEILISEARCH_DOCS_COUNT: IntGaugeVec = register_int_gauge_vec!(
|
||||||
opts!("meilisearch_docs_count", "MeiliSearch Stats Docs Count"),
|
opts!("meilisearch_docs_count", "MeiliSearch Stats Docs Count"),
|
||||||
&["index"]
|
&["index"]
|
||||||
)
|
)
|
||||||
.expect("Can't create a metric");
|
.expect("Can't create a metric");
|
||||||
|
|
||||||
pub static ref HTTP_RESPONSE_TIME_SECONDS: HistogramVec = register_histogram_vec!(
|
pub static ref HTTP_RESPONSE_TIME_SECONDS: HistogramVec = register_histogram_vec!(
|
||||||
"http_response_time_seconds",
|
"http_response_time_seconds",
|
||||||
"HTTP response times",
|
"HTTP response times",
|
||||||
@ -37,4 +38,4 @@ lazy_static! {
|
|||||||
HTTP_RESPONSE_TIME_CUSTOM_BUCKETS.to_vec()
|
HTTP_RESPONSE_TIME_CUSTOM_BUCKETS.to_vec()
|
||||||
)
|
)
|
||||||
.expect("Can't create a metric");
|
.expect("Can't create a metric");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use actix_web::{web, HttpResponse};
|
|
||||||
use actix_web::http::header::{self};
|
use actix_web::http::header::{self};
|
||||||
|
use actix_web::{web, HttpResponse};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -285,20 +285,17 @@ pub async fn get_health() -> Result<HttpResponse, ResponseError> {
|
|||||||
pub async fn get_metrics(
|
pub async fn get_metrics(
|
||||||
meilisearch: GuardedData<ActionPolicy<{ actions::STATS_GET }>, MeiliSearch>,
|
meilisearch: GuardedData<ActionPolicy<{ actions::STATS_GET }>, MeiliSearch>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
|
|
||||||
let search_rules = &meilisearch.filters().search_rules;
|
let search_rules = &meilisearch.filters().search_rules;
|
||||||
let response = meilisearch.get_all_stats(search_rules).await?;
|
let response = meilisearch.get_all_stats(search_rules).await?;
|
||||||
|
|
||||||
crate::metrics::MEILISEARCH_DB_SIZE
|
crate::metrics::MEILISEARCH_DB_SIZE.set(response.database_size as i64);
|
||||||
.set(response.database_size as i64);
|
|
||||||
|
|
||||||
crate::metrics::MEILISEARCH_INDEX_COUNT
|
crate::metrics::MEILISEARCH_INDEX_COUNT.set(response.indexes.len() as i64);
|
||||||
.set(response.indexes.len() as i64);
|
|
||||||
|
|
||||||
for (index, value) in response.indexes.iter() {
|
for (index, value) in response.indexes.iter() {
|
||||||
crate::metrics::MEILISEARCH_DOCS_COUNT
|
crate::metrics::MEILISEARCH_DOCS_COUNT
|
||||||
.with_label_values(&[&index])
|
.with_label_values(&[index])
|
||||||
.set(value.number_of_documents as i64);
|
.set(value.number_of_documents as i64);
|
||||||
}
|
}
|
||||||
|
|
||||||
let encoder = TextEncoder::new();
|
let encoder = TextEncoder::new();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user