исправить: закрыть ревью сквозной корреляции
This commit is contained in:
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use axum::{
|
||||
body::Body,
|
||||
http::{Request, StatusCode},
|
||||
http::{HeaderValue, Request, StatusCode},
|
||||
};
|
||||
use opentelemetry::{
|
||||
global,
|
||||
@@ -23,9 +23,11 @@ use tracing_subscriber::layer::SubscriberExt;
|
||||
use super::common::{build_test_app, test_registry};
|
||||
|
||||
const REMOTE_TRACE_ID: &str = "0af7651916cd43dd8448eb211c80319c";
|
||||
static TRACING_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
|
||||
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
async fn covers_valid_invalid_and_absent_traceparent_on_mcp_boundary() {
|
||||
let _tracing_test_guard = TRACING_TEST_LOCK.lock().await;
|
||||
global::set_text_map_propagator(TraceContextPropagator::new());
|
||||
let exported = Arc::new(Mutex::new(Vec::new()));
|
||||
let provider = SdkTracerProvider::builder()
|
||||
@@ -81,6 +83,37 @@ async fn covers_valid_invalid_and_absent_traceparent_on_mcp_boundary() {
|
||||
provider.shutdown().unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn replaces_multiple_request_id_headers_with_one_uuid_v7() {
|
||||
let _tracing_test_guard = TRACING_TEST_LOCK.lock().await;
|
||||
let app = build_test_app(test_registry().await, Duration::ZERO, None);
|
||||
let mut request = Request::builder()
|
||||
.uri("/health")
|
||||
.body(Body::empty())
|
||||
.unwrap();
|
||||
request
|
||||
.headers_mut()
|
||||
.append("x-request-id", HeaderValue::from_static("first-request-id"));
|
||||
request.headers_mut().append(
|
||||
"x-request-id",
|
||||
HeaderValue::from_static("second-request-id"),
|
||||
);
|
||||
|
||||
let response = app
|
||||
.oneshot(request)
|
||||
.with_subscriber(tracing_subscriber::registry())
|
||||
.await
|
||||
.unwrap();
|
||||
let generated = response.headers()["x-request-id"].to_str().unwrap();
|
||||
|
||||
assert_ne!(generated, "first-request-id");
|
||||
assert_ne!(generated, "second-request-id");
|
||||
assert_eq!(
|
||||
uuid::Uuid::parse_str(generated).unwrap().get_version(),
|
||||
Some(uuid::Version::SortRand)
|
||||
);
|
||||
}
|
||||
|
||||
async fn send_health(
|
||||
app: axum::Router,
|
||||
traceparent: Option<&str>,
|
||||
|
||||
Reference in New Issue
Block a user