наблюдаемость: завершить базовый контур Community
CI / Rust Checks (push) Failing after 4m28s
CI / UI Checks (push) Has been skipped
CI / Frontend E2E (push) Has been skipped
CI / Community Image Smoke (push) Has been skipped
CI / Deploy (push) Has been skipped

Добавить структурированные журналы, метрики, трассировку и безопасный канал критических ошибок. Усилить границы рантайма, тесты, проверку зависимостей и сценарии развёртывания.
This commit is contained in:
2026-07-31 01:01:14 +03:00
parent 99bd05c145
commit 0e8f1ca03a
160 changed files with 13506 additions and 1499 deletions
@@ -0,0 +1,39 @@
use axum::{extract::Request, http::HeaderValue, middleware::Next, response::Response};
use crank_observability::{RequestId, set_remote_trace_parent, with_request_correlation};
use tracing::{Instrument, info_span};
use crate::transport::HEADER_X_REQUEST_ID;
#[derive(Clone, Debug)]
pub(super) struct RequestContext {
pub(super) request_id: String,
}
pub(super) async fn apply_request_context(mut request: Request, next: Next) -> Response {
let request_id = RequestId::resolve(
request
.headers()
.get(&HEADER_X_REQUEST_ID)
.and_then(|value| value.to_str().ok()),
)
.into_string();
let context = RequestContext {
request_id: request_id.clone(),
};
let span = info_span!(
target: "crank::trace",
"mcp.request",
request_id = %request_id,
);
set_remote_trace_parent(&span, request.headers());
request.extensions_mut().insert(context);
with_request_correlation(request_id.clone(), async move {
let mut response = next.run(request).instrument(span).await;
if let Ok(value) = HeaderValue::from_str(&request_id) {
response.headers_mut().insert(HEADER_X_REQUEST_ID, value);
}
response
})
.await
}