fix: harden typed metrics review findings
This commit is contained in:
1 parent
996a5461de
commit
b7face0e94
30 files changed
+722
-382
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user