fix: harden typed metrics review findings

This commit is contained in:
bsodfather committed 2026-08-14 13:50:04 +03:00
1 parent 996a5461de
commit b7face0e94
30 files changed
+722 -382

No files matched your search

+10 -11
View File
@@ -19,32 +19,31 @@ pub(super) struct McpRequestMetrics {
}
impl McpRequestMetrics {
pub(super) fn invalid() -> Self {
pub(super) fn invalid(started_at: Instant, exemplar: Option<ExemplarTraceId>) -> Self {
Self {
method: McpMethod::Invalid,
response_mode: McpResponseMode::Unknown,
outcome: McpOutcome::Aborted,
started_at: Instant::now(),
exemplar: None,
started_at,
exemplar,
}
}
pub(super) fn new(message: &Value) -> Self {
pub(super) fn new(
message: &Value,
started_at: Instant,
exemplar: Option<ExemplarTraceId>,
) -> Self {
Self {
method: normalized_mcp_method(message),
response_mode: McpResponseMode::Unknown,
outcome: McpOutcome::Aborted,
started_at: Instant::now(),
exemplar: None,
started_at,
exemplar,
}
}
pub(super) fn complete(&mut self, response: &Response) {
self.exemplar = response
.headers()
.get("x-trace-id")
.and_then(|value| value.to_str().ok())
.and_then(ExemplarTraceId::parse);
self.response_mode = response
.headers()
.get(CONTENT_TYPE)