@@ -69,10 +69,10 @@ use http::{
69
69
Uri ,
70
70
} ;
71
71
use itertools:: Itertools ;
72
- use maplit:: btreemap;
73
72
use minitrace:: {
74
73
future:: FutureExt as _,
75
74
prelude:: SpanContext ,
75
+ Span ,
76
76
} ;
77
77
use prometheus:: {
78
78
PullingGauge ,
@@ -103,10 +103,6 @@ use crate::{
103
103
errors:: report_error,
104
104
knobs:: HTTP_SERVER_TCP_BACKLOG ,
105
105
metrics:: log_client_version_unsupported,
106
- minitrace_helpers:: {
107
- get_keyed_sampled_span,
108
- get_sampled_span,
109
- } ,
110
106
version:: {
111
107
ClientVersion ,
112
108
ClientVersionState ,
@@ -803,7 +799,6 @@ pub async fn stats_middleware<RM: RouteMapper>(
803
799
State ( route_metric_mapper) : State < RM > ,
804
800
matched_path : Option < axum:: extract:: MatchedPath > ,
805
801
ExtractRequestId ( request_id) : ExtractRequestId ,
806
- ExtractResolvedHostname ( resolved_host) : ExtractResolvedHostname ,
807
802
ExtractClientVersion ( client_version) : ExtractClientVersion ,
808
803
ExtractTraceparent ( traceparent) : ExtractTraceparent ,
809
804
req : http:: request:: Request < Body > ,
@@ -817,29 +812,12 @@ pub async fn stats_middleware<RM: RouteMapper>(
817
812
. map ( |r| r. as_str ( ) . to_owned ( ) )
818
813
. unwrap_or ( "unknown" . to_owned ( ) ) ;
819
814
820
- // Configure tracing. Prefer path to route - since matched path can have *,
821
- // notably for /http/*rest
815
+ // Sampling isn't done here, and should be done upstream
822
816
let path = req. uri ( ) . path ( ) ;
823
- let root = {
824
- if let Some ( span_ctx) = traceparent {
825
- get_keyed_sampled_span (
826
- span_ctx. trace_id ,
827
- & resolved_host. instance_name ,
828
- path,
829
- span_ctx,
830
- btreemap ! [ "request_id" . to_owned( ) => request_id. to_string( ) ] ,
831
- )
832
- } else {
833
- let mut rng = rand:: thread_rng ( ) ;
834
- get_sampled_span (
835
- & resolved_host. instance_name ,
836
- path,
837
- & mut rng,
838
- btreemap ! [ "request_id" . to_owned( ) => request_id. to_string( ) ] ,
839
- )
840
- }
817
+ let root = match traceparent {
818
+ Some ( span_ctx) => Span :: root ( path. to_owned ( ) , span_ctx) ,
819
+ None => Span :: noop ( ) ,
841
820
} ;
842
-
843
821
let resp = next. run ( req) . in_span ( root) . await ;
844
822
845
823
let client_version_s = client_version. to_string ( ) ;
0 commit comments