CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-opentelemetry--instrumentation-express

OpenTelemetry instrumentation for Express.js web applications enabling automatic distributed tracing and observability

80

1.63x
Overview
Eval results
Files

task.mdevals/scenario-7/

Route Information Collector

Build a utility that collects and reports route path information from HTTP requests in an Express.js application.

Requirements

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:

  • Simple static routes (e.g., /api/health)
  • Parameterized routes (e.g., /users/:userId)
  • Nested router configurations
  • Routes mounted at specific paths

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.

Test Cases

  • When a request matches /users/:userId, the captured route should be /users/:userId not the actual path like /users/123 @test
  • When a request is handled by a nested router mounted at /api with internal route /products/:id, the full route should be captured as /api/products/:id @test
  • When a request matches /health, the route should be captured as /health @test

Implementation

@generates

API

/**
 * 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;

Dependencies { .dependencies }

express { .dependency }

Provides web application framework.

@opentelemetry/instrumentation-express { .dependency }

Provides automatic instrumentation for Express.js applications.

@opentelemetry/api { .dependency }

Provides OpenTelemetry API for accessing trace context and spans.

Install with Tessl CLI

npx tessl i tessl/npm-opentelemetry--instrumentation-express

tile.json