mirror of
https://github.com/mozilla-services/syncstorage-rs.git
synced 2026-05-06 04:36:28 +02:00
fix: don't add extra prefixes to middleware emitted metrics (#1630)
Closes SYNC-4478
This commit is contained in:
parent
3ed6d6077c
commit
9b033edcb0
@ -14,15 +14,13 @@ use crate::{ReportableError, Taggable};
|
||||
#[derive(Clone)]
|
||||
pub struct SentryWrapper<E> {
|
||||
metrics: Arc<StatsdClient>,
|
||||
metric_label: String,
|
||||
phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<E> SentryWrapper<E> {
|
||||
pub fn new(metrics: Arc<StatsdClient>, metric_label: String) -> Self {
|
||||
pub fn new(metrics: Arc<StatsdClient>) -> Self {
|
||||
Self {
|
||||
metrics,
|
||||
metric_label,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
@ -44,7 +42,6 @@ where
|
||||
ok(SentryWrapperMiddleware {
|
||||
service: Rc::new(RefCell::new(service)),
|
||||
metrics: self.metrics.clone(),
|
||||
metric_label: self.metric_label.clone(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
}
|
||||
@ -54,7 +51,6 @@ where
|
||||
pub struct SentryWrapperMiddleware<S, E> {
|
||||
service: Rc<RefCell<S>>,
|
||||
metrics: Arc<StatsdClient>,
|
||||
metric_label: String,
|
||||
phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
@ -81,7 +77,6 @@ where
|
||||
|
||||
// get the tag information
|
||||
let metrics = self.metrics.clone();
|
||||
let metric_label = self.metric_label.clone();
|
||||
let tags = sreq.get_tags();
|
||||
let extras = sreq.get_extras();
|
||||
|
||||
@ -100,7 +95,7 @@ where
|
||||
// capture it, and then turn it off before we run out of money.
|
||||
if let Some(label) = reportable_err.metric_label() {
|
||||
debug!("Sentry: Sending error to metrics: {:?}", reportable_err);
|
||||
let _ = metrics.incr(&format!("{}.{}", metric_label, label));
|
||||
let _ = metrics.incr(&label);
|
||||
}
|
||||
debug!("Sentry: Not reporting error (service error): {:?}", error);
|
||||
return Err(error);
|
||||
@ -122,7 +117,7 @@ where
|
||||
if !reportable_err.is_sentry_event() {
|
||||
if let Some(label) = reportable_err.metric_label() {
|
||||
debug!("Sentry: Sending error to metrics: {:?}", reportable_err);
|
||||
let _ = metrics.incr(&format!("{}.{}", metric_label, label));
|
||||
let _ = metrics.incr(&label);
|
||||
}
|
||||
debug!("Not reporting error (service error): {:?}", error);
|
||||
return Ok(response);
|
||||
|
||||
@ -88,10 +88,7 @@ macro_rules! build_app {
|
||||
// These will wrap all outbound responses with matching status codes.
|
||||
.wrap(ErrorHandlers::new().handler(StatusCode::NOT_FOUND, ApiError::render_404))
|
||||
// These are our wrappers
|
||||
.wrap(SentryWrapper::<ApiError>::new(
|
||||
$metrics.clone(),
|
||||
"api_error".to_owned(),
|
||||
))
|
||||
.wrap(SentryWrapper::<ApiError>::new($metrics.clone()))
|
||||
.wrap_fn(middleware::weave::set_weave_timestamp)
|
||||
.wrap_fn(tokenserver::logging::handle_request_log_line)
|
||||
.wrap_fn(middleware::rejectua::reject_user_agent)
|
||||
@ -199,7 +196,6 @@ macro_rules! build_app_without_syncstorage {
|
||||
.wrap(ErrorHandlers::new().handler(StatusCode::NOT_FOUND, ApiError::render_404))
|
||||
.wrap(SentryWrapper::<tokenserver_common::TokenserverError>::new(
|
||||
$metrics.clone(),
|
||||
"api_error".to_owned(),
|
||||
))
|
||||
// These are our wrappers
|
||||
.wrap_fn(tokenserver::logging::handle_request_log_line)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user