Skip to content

Commit e182513

Browse files
jordanhunt22Convex, Inc.
authored andcommitted
[Tracing] Make tracing start in usher for all endpoints (#29826)
GitOrigin-RevId: 87674e2fce5df78f547f625e90a92ade9153b147
1 parent a48182b commit e182513

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

crates/common/src/http/mod.rs

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ use http::{
6969
Uri,
7070
};
7171
use itertools::Itertools;
72-
use maplit::btreemap;
7372
use minitrace::{
7473
future::FutureExt as _,
7574
prelude::SpanContext,
75+
Span,
7676
};
7777
use prometheus::{
7878
PullingGauge,
@@ -103,10 +103,6 @@ use crate::{
103103
errors::report_error,
104104
knobs::HTTP_SERVER_TCP_BACKLOG,
105105
metrics::log_client_version_unsupported,
106-
minitrace_helpers::{
107-
get_keyed_sampled_span,
108-
get_sampled_span,
109-
},
110106
version::{
111107
ClientVersion,
112108
ClientVersionState,
@@ -803,7 +799,6 @@ pub async fn stats_middleware<RM: RouteMapper>(
803799
State(route_metric_mapper): State<RM>,
804800
matched_path: Option<axum::extract::MatchedPath>,
805801
ExtractRequestId(request_id): ExtractRequestId,
806-
ExtractResolvedHostname(resolved_host): ExtractResolvedHostname,
807802
ExtractClientVersion(client_version): ExtractClientVersion,
808803
ExtractTraceparent(traceparent): ExtractTraceparent,
809804
req: http::request::Request<Body>,
@@ -817,29 +812,12 @@ pub async fn stats_middleware<RM: RouteMapper>(
817812
.map(|r| r.as_str().to_owned())
818813
.unwrap_or("unknown".to_owned());
819814

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
822816
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(),
841820
};
842-
843821
let resp = next.run(req).in_span(root).await;
844822

845823
let client_version_s = client_version.to_string();

0 commit comments

Comments
 (0)