feat: improve Tokenserver errors and metrics (#1385)

This commit is contained in:
Ethan Donowitz 2022-08-25 09:04:16 -04:00 committed by GitHub
parent edef90ca47
commit 90f1017341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 7 deletions

View File

@ -297,6 +297,9 @@ impl TokenserverDb {
&self,
params: params::AddUserToNode,
) -> DbResult<results::AddUserToNode> {
let mut metrics = self.metrics.clone();
metrics.start_timer("storage.add_user_to_node", None);
const QUERY: &str = r#"
UPDATE nodes
SET current_load = current_load + 1,

View File

@ -42,6 +42,7 @@ use crate::tokenserver::auth::TokenserverOrigin;
use crate::web::{
auth::HawkPayload,
error::{HawkErrorKind, ValidationErrorKind},
tags::Tags,
DOCKER_FLOW_ENDPOINTS, X_WEAVE_RECORDS,
};
const BATCH_MAX_IDS: usize = 100;
@ -1161,13 +1162,20 @@ impl FromRequest for HawkIdentifier {
}
};
future::ready(Self::extrude(
&req,
method.as_str(),
uri,
&connection_info,
secrets,
))
let result = Self::extrude(&req, method.as_str(), uri, &connection_info, secrets);
if let Ok(ref hawk_id) = result {
// Store the origin of the token as an extra to be included when emitting a Sentry error
let mut exts = req.extensions_mut();
let mut tags = Tags::default();
tags.add_extra(
"tokenserver_origin",
&hawk_id.tokenserver_origin.to_string(),
);
tags.commit(&mut exts);
}
future::ready(result)
}
}