clippy & rustfmt fixed

This commit is contained in:
mohandasspat 2022-08-08 11:11:38 +05:30
parent de58ccd4ba
commit d08c77706c
3 changed files with 24 additions and 25 deletions

View File

@ -7,7 +7,6 @@ pub mod task;
pub mod extractors;
pub mod option;
pub mod routes;
pub mod metrics;
use std::sync::{atomic::AtomicBool, Arc};
use std::time::Duration;
@ -145,19 +144,21 @@ pub fn dashboard(config: &mut web::ServiceConfig, _enable_frontend: bool) {
macro_rules! create_app {
($data:expr, $auth:expr, $enable_frontend:expr, $opt:expr, $analytics:expr) => {{
use actix_cors::Cors;
use actix_web::dev::Service;
use actix_web::middleware::TrailingSlash;
use actix_web::App;
use actix_web::dev::Service;
use actix_web::{middleware, web};
use meilisearch_http::error::MeilisearchHttpError;
use meilisearch_http::metrics;
use meilisearch_http::routes;
use meilisearch_http::{configure_data, dashboard};
use meilisearch_types::error::ResponseError;
use meilisearch_http::metrics;
use lazy_static::lazy_static;
use prometheus::{opts, register_histogram_vec, register_int_counter_vec, register_int_gauge};
use prometheus::{HistogramVec, IntCounterVec, IntGauge, HistogramTimer};
use prometheus::{
opts, register_histogram_vec, register_int_counter_vec, register_int_gauge,
};
use prometheus::{HistogramTimer, HistogramVec, IntCounterVec, IntGauge};
App::new()
.configure(|s| configure_data(s, $data.clone(), $auth.clone(), &$opt, $analytics))

View File

@ -1,5 +1,8 @@
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};
const HTTP_RESPONSE_TIME_CUSTOM_BUCKETS: &[f64; 14] = &[
@ -13,23 +16,21 @@ lazy_static! {
&["method", "path"]
)
.expect("Can't create a metric");
pub static ref MEILISEARCH_DB_SIZE: IntGauge = register_int_gauge!(
opts!("meilisearch_database_size", "MeiliSearch Stats DbSize")
)
pub static ref MEILISEARCH_DB_SIZE: IntGauge = register_int_gauge!(opts!(
"meilisearch_database_size",
"MeiliSearch Stats DbSize"
))
.expect("Can't create a metric");
pub static ref MEILISEARCH_INDEX_COUNT: IntGauge = register_int_gauge!(
opts!("meilisearch_total_index", "MeiliSearch Stats Index Count")
)
pub static ref MEILISEARCH_INDEX_COUNT: IntGauge = register_int_gauge!(opts!(
"meilisearch_total_index",
"MeiliSearch Stats Index Count"
))
.expect("Can't create a metric");
pub static ref MEILISEARCH_DOCS_COUNT: IntGaugeVec = register_int_gauge_vec!(
opts!("meilisearch_docs_count", "MeiliSearch Stats Docs Count"),
&["index"]
)
.expect("Can't create a metric");
pub static ref HTTP_RESPONSE_TIME_SECONDS: HistogramVec = register_histogram_vec!(
"http_response_time_seconds",
"HTTP response times",

View File

@ -1,5 +1,5 @@
use actix_web::{web, HttpResponse};
use actix_web::http::header::{self};
use actix_web::{web, HttpResponse};
use log::debug;
use serde::{Deserialize, Serialize};
@ -276,19 +276,16 @@ pub async fn get_health() -> Result<HttpResponse, ResponseError> {
pub async fn get_metrics(
meilisearch: GuardedData<ActionPolicy<{ actions::STATS_GET }>, MeiliSearch>,
) -> Result<HttpResponse, ResponseError> {
let search_rules = &meilisearch.filters().search_rules;
let response = meilisearch.get_all_stats(search_rules).await?;
crate::metrics::MEILISEARCH_DB_SIZE
.set(response.database_size as i64);
crate::metrics::MEILISEARCH_DB_SIZE.set(response.database_size as i64);
crate::metrics::MEILISEARCH_INDEX_COUNT
.set(response.indexes.len() as i64);
crate::metrics::MEILISEARCH_INDEX_COUNT.set(response.indexes.len() as i64);
for (index, value) in response.indexes.iter() {
crate::metrics::MEILISEARCH_DOCS_COUNT
.with_label_values(&[&index])
.with_label_values(&[index])
.set(value.number_of_documents as i64);
}