dvStartServerSpan function

DVSpan dvStartServerSpan(
  1. DVTracer tracer,
  2. Request request
)

The server span for request, by the HTTP semantic conventions.

Named by the method alone until the route is known: the path is where ids are, and one span name per order id is how a tracing backend's index is blown up by the application it watches. dvRecordHttpRoute renames it.

Implementation

DVSpan dvStartServerSpan(DVTracer tracer, Request request) {
  final String method = request.method;
  return tracer.startSpan(
    method,
    kind: DVSpanKind.server,
    context: DVTraceContext.parse(request.headers.get('traceparent')),
    attributes: <String, Object>{
      'http.request.method': method,
      'url.path': request.url.path,
      'url.scheme': request.url.scheme.isEmpty ? 'http' : request.url.scheme,
      if (request.url.host.isNotEmpty) 'server.address': request.url.host,
      if (request.url.hasPort) 'server.port': request.url.port,
      if (request.headers.get('user-agent') case final String agent)
        'user_agent.original': agent,
    },
  );
}