docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a utility that collects and reports route path information from HTTP requests in an Express.js application.
Your solution should capture the matched route template for each incoming HTTP request and make it available for logging or monitoring purposes. The system should handle various route patterns including:
/api/health)/users/:userId)The captured route information should be accessible during request processing so it can be logged alongside other request metadata like status codes and response times.
/users/:userId, the captured route should be /users/:userId not the actual path like /users/123 @test/api with internal route /products/:id, the full route should be captured as /api/products/:id @test/health, the route should be captured as /health @test/**
* Initializes route tracking for the Express application
* @param app - The Express application instance
*/
export function setupRouteTracking(app: Express): void;
/**
* Retrieves the matched route template for the current request
* @param req - The Express request object
* @returns The route template (e.g., "/users/:id") or null if not available
*/
export function getMatchedRoute(req: Request): string | null;Provides web application framework.
Provides automatic instrumentation for Express.js applications.
Provides OpenTelemetry API for accessing trace context and spans.