Creates a @cleverbrush/server middleware that opens an OpenTelemetry SERVER span for every incoming request.
@cleverbrush/server
SERVER
Register first with useRequest() so that the span wraps CORS, auth, request logging, and the handler — capturing the full request lifetime.
useRequest()
Behavior:
traceparent
baggage
${operationId}
${method} ${http.route}
${method}
http.request.method
url.path
url.scheme
server.address
user_agent.original
http.route
ctx.items.get(OTEL_SPAN_ITEM_KEY)
Optional
tracing configuration
a Middleware compatible with @cleverbrush/server
Middleware
import { tracingMiddleware } from '@cleverbrush/otel';createServer() .useRequest(tracingMiddleware({ excludePaths: ['/health'] })) .use(corsMiddleware) .use(authMiddleware) .listen(3000); Copy
import { tracingMiddleware } from '@cleverbrush/otel';createServer() .useRequest(tracingMiddleware({ excludePaths: ['/health'] })) .use(corsMiddleware) .use(authMiddleware) .listen(3000);
Creates a
@cleverbrush/servermiddleware that opens an OpenTelemetrySERVERspan for every incoming request.Register first with
useRequest()so that the span wraps CORS, auth, request logging, and the handler — capturing the full request lifetime.Behavior:
traceparent,baggage).${operationId}if available, otherwise${method} ${http.route}, otherwise${method}.http.request.method,url.path,url.scheme,server.address,user_agent.original,http.route).ctx.items.get(OTEL_SPAN_ITEM_KEY)for downstream code to enrich.