fix: harden typed metrics review findings
This commit is contained in:
@@ -24,6 +24,7 @@ crank-config = { path = "../../crates/crank-config" }
|
||||
crank-core = { path = "../../crates/crank-core" }
|
||||
crank-import = { path = "../../crates/crank-import" }
|
||||
crank-mapping = { path = "../../crates/crank-mapping" }
|
||||
crank-metrics = { path = "../../crates/crank-metrics" }
|
||||
crank-observability = { path = "../../crates/crank-observability" }
|
||||
crank-registry = { path = "../../crates/crank-registry" }
|
||||
crank-runtime = { path = "../../crates/crank-runtime" }
|
||||
|
||||
@@ -5,6 +5,7 @@ use axum::{
|
||||
response::Response,
|
||||
};
|
||||
use crank_core::{CorrelationContext, RequestId, TraceContext};
|
||||
use crank_metrics::ExemplarTraceId;
|
||||
use crank_observability::{set_remote_trace_parent, with_request_correlation};
|
||||
use tracing::{Instrument, info, info_span};
|
||||
|
||||
@@ -74,6 +75,12 @@ pub async fn apply_request_context(mut request: Request, next: Next) -> Response
|
||||
if let Ok(value) = HeaderValue::from_str(context.correlation.trace_id().as_str()) {
|
||||
response.headers_mut().insert(TRACE_ID_HEADER, value);
|
||||
}
|
||||
if context.correlation.trace_context().is_sampled()
|
||||
&& let Some(exemplar) =
|
||||
ExemplarTraceId::parse(context.correlation.trace_id().as_str())
|
||||
{
|
||||
response.extensions_mut().insert(exemplar);
|
||||
}
|
||||
response
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user