dvRecordHttpRoute function

void dvRecordHttpRoute(
  1. String route
)

Names the current request's server span after route, the template the request matched (/orders/:id), as the semantic conventions name a span.

The router calls this when it matches; the page server and Studio call it for the routes they answer. Outside a request it does nothing.

Implementation

void dvRecordHttpRoute(String route) {
  final DVRequestTelemetry? scope = DVRequestTelemetry.current;
  scope?.route = route;
  // The request's own server span, even from inside a child span -- the
  // page server matches its route inside the render span.
  final DVSpan? current = dvCurrentSpan;
  final DVSpan? span = scope?.span ??
      (current != null && current.kind == DVSpanKind.server ? current : null);
  if (span == null) return;
  span
    ..updateName('${span.attributes['http.request.method'] ?? ''} $route'.trim())
    ..setAttribute('http.route', route);
}