mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-11 07:28:56 +01:00
Merge #3496
3496: Fix metrics feature r=irevoire a=james-2001 # Pull Request ## Related issue Resolves: #3469 See also: #2763 ## What does this PR do? As reported the metrics feature was broken by still using and old reference to `meilisearch_auth::actions`. This commit switches to the new location, `meilisearch_types::keys::actions`. The original issue was not *that* clear as to exactly what was broken, and the build logs have disappeared, but it seemed to just be this one line fix. If this is not the case and I've missed the mark let me know, and i'll head back to the drawing board. ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Co-authored-by: James <james.a.may.2001@gmail.com>
This commit is contained in:
commit
a3e41ba33e
@ -249,6 +249,8 @@ impl From<Opt> for Infos {
|
|||||||
// to add analytics when we add a field in the Opt.
|
// to add analytics when we add a field in the Opt.
|
||||||
// Thus we must not insert `..` at the end.
|
// Thus we must not insert `..` at the end.
|
||||||
let Opt {
|
let Opt {
|
||||||
|
#[cfg(features = "metrics")]
|
||||||
|
enable_metrics_route: _,
|
||||||
db_path,
|
db_path,
|
||||||
http_addr,
|
http_addr,
|
||||||
master_key: _,
|
master_key: _,
|
||||||
|
@ -92,7 +92,8 @@ pub fn create_app(
|
|||||||
let app = app.configure(|s| configure_metrics_route(s, opt.enable_metrics_route));
|
let app = app.configure(|s| configure_metrics_route(s, opt.enable_metrics_route));
|
||||||
|
|
||||||
#[cfg(feature = "metrics")]
|
#[cfg(feature = "metrics")]
|
||||||
let app = app.wrap(Condition::new(opt.enable_metrics_route, route_metrics::RouteMetrics));
|
let app =
|
||||||
|
app.wrap(middleware::Condition::new(opt.enable_metrics_route, route_metrics::RouteMetrics));
|
||||||
app.wrap(
|
app.wrap(
|
||||||
Cors::default()
|
Cors::default()
|
||||||
.send_wildcard()
|
.send_wildcard()
|
||||||
|
@ -2,21 +2,26 @@ use std::future::{ready, Ready};
|
|||||||
|
|
||||||
use actix_web::dev::{self, Service, ServiceRequest, ServiceResponse, Transform};
|
use actix_web::dev::{self, Service, ServiceRequest, ServiceResponse, Transform};
|
||||||
use actix_web::http::header;
|
use actix_web::http::header;
|
||||||
|
use actix_web::web::Data;
|
||||||
use actix_web::{Error, HttpResponse};
|
use actix_web::{Error, HttpResponse};
|
||||||
use futures_util::future::LocalBoxFuture;
|
use futures_util::future::LocalBoxFuture;
|
||||||
use meilisearch_auth::actions;
|
use index_scheduler::IndexScheduler;
|
||||||
use meilisearch_lib::MeiliSearch;
|
use meilisearch_auth::AuthController;
|
||||||
use meilisearch_types::error::ResponseError;
|
use meilisearch_types::error::ResponseError;
|
||||||
|
use meilisearch_types::keys::actions;
|
||||||
use prometheus::{Encoder, HistogramTimer, TextEncoder};
|
use prometheus::{Encoder, HistogramTimer, TextEncoder};
|
||||||
|
|
||||||
use crate::extractors::authentication::policies::ActionPolicy;
|
use crate::extractors::authentication::policies::ActionPolicy;
|
||||||
use crate::extractors::authentication::GuardedData;
|
use crate::extractors::authentication::GuardedData;
|
||||||
|
use crate::routes::create_all_stats;
|
||||||
|
|
||||||
pub async fn get_metrics(
|
pub async fn get_metrics(
|
||||||
meilisearch: GuardedData<ActionPolicy<{ actions::METRICS_GET }>, MeiliSearch>,
|
index_scheduler: GuardedData<ActionPolicy<{ actions::METRICS_GET }>, Data<IndexScheduler>>,
|
||||||
|
auth_controller: GuardedData<ActionPolicy<{ actions::METRICS_GET }>, AuthController>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let search_rules = &meilisearch.filters().search_rules;
|
let search_rules = &index_scheduler.filters().search_rules;
|
||||||
let response = meilisearch.get_all_stats(search_rules).await?;
|
let response =
|
||||||
|
create_all_stats((*index_scheduler).clone(), (*auth_controller).clone(), search_rules)?;
|
||||||
|
|
||||||
crate::metrics::MEILISEARCH_DB_SIZE_BYTES.set(response.database_size as i64);
|
crate::metrics::MEILISEARCH_DB_SIZE_BYTES.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);
|
||||||
|
Loading…
Reference in New Issue
Block a user