or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

Request Filtering Service

Build a request filtering service for an Express.js application that prevents certain routes from being traced by OpenTelemetry instrumentation.

Overview

Your task is to create an Express.js HTTP server that implements request filtering to exclude specific endpoints from distributed tracing. The service should coordinate filtering across both HTTP and Express instrumentation layers to avoid creating partial traces.

Requirements

Server Setup

Create an Express server on port 3000 with the following routes:

  • GET /api/data - Returns {"message": "data endpoint"}
  • GET /health - Returns {"status": "healthy"}
  • GET /metrics - Returns {"metrics": "system metrics"}
  • GET /api/users/:id - Returns {"userId": "<id>", "name": "User <id>"}

Instrumentation Configuration

Configure OpenTelemetry instrumentation for your Express application with the following requirements:

  1. HTTP Layer Filtering: Configure the HTTP instrumentation to ignore requests to /health and /metrics endpoints completely, preventing root span creation
  2. Express Instrumentation: Enable Express instrumentation to work with the HTTP instrumentation
  3. Trace Export: Configure a console exporter to output span information for verification

Expected Behavior

  • Requests to /api/data and /api/users/:id should create traces (both root HTTP spans and Express layer spans)
  • Requests to /health and /metrics should NOT create any spans at all
  • The filtering should prevent partial traces (no orphaned Express spans without HTTP parent spans)

Test Cases

  • Server responds to GET /api/data with correct JSON and creates traces @test
  • Server responds to GET /health with correct JSON but does NOT create any traces @test
  • Server responds to GET /metrics with correct JSON but does NOT create any traces @test
  • Server responds to GET /api/users/123 with correct JSON and creates traces @test

Dependencies { .dependencies }

@opentelemetry/instrumentation-express { .dependency }

Provides automatic instrumentation for Express.js applications to create spans for middleware, routers, and request handlers.

@opentelemetry/instrumentation-http { .dependency }

Provides automatic instrumentation for HTTP server and client requests, creating root spans for incoming requests.

@opentelemetry/sdk-trace-node { .dependency }

Provides the OpenTelemetry NodeJS SDK for trace collection and processing.

express { .dependency }

Web application framework for Node.js.

Implementation

@generates

API

// Express server that starts listening on port 3000
// Exports the configured Express app instance for testing
export const app: Express;

// Starts the server
export function startServer(): void;