or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-1/

Express Version Compatibility Testing

Build a testing utility that verifies OpenTelemetry instrumentation works correctly across different Express versions (v4 and v5). The utility should set up instrumented Express applications and validate that spans are created properly regardless of Express version.

Requirements

Create a testing utility that:

  1. Sets up Express applications with OpenTelemetry instrumentation for both v4 and v5
  2. Creates test endpoints in the Express apps to generate trace spans
  3. Validates that the instrumentation correctly captures spans in both versions
  4. Extracts and compares span data from v4 and v5 applications to ensure consistent behavior

Expected Behavior

  • The utility should initialize OpenTelemetry tracing with an in-memory exporter
  • Apply the Express instrumentation to test applications
  • Create at least one middleware and one route handler in each app
  • Trigger HTTP requests to generate spans
  • Verify that spans are created with the correct attributes (route, layer type, etc.)
  • Confirm that both v4 and v5 apps produce valid span data

@generates

API

/**
 * Sets up an instrumented Express v4 or v5 app
 * Returns the app and a function to get collected spans
 */
export function setupInstrumentedApp(version: 'v4' | 'v5'): {
  app: any;
  getSpans: () => any[];
  cleanup: () => void;
};

/**
 * Verifies that spans were created correctly for the given request
 * Checks for expected span names, attributes, and structure
 */
export function verifySpans(spans: any[], expectedRoute: string): boolean;

/**
 * Compares spans from v4 and v5 apps to ensure compatibility
 * Returns true if spans have consistent structure and attributes
 */
export function compareVersionSpans(v4Spans: any[], v5Spans: any[]): boolean;

Test Cases

  • Setting up an instrumented Express v4 app creates an app instance and span collector @test
  • Setting up an instrumented Express v5 app creates an app instance and span collector @test
  • Making a request to an instrumented v4 app generates spans with route information @test
  • Making a request to an instrumented v5 app generates spans with route information @test
  • Spans from v4 and v5 apps have consistent structure and attributes @test

Dependencies { .dependencies }

@opentelemetry/instrumentation-express { .dependency }

Provides OpenTelemetry instrumentation for Express.js with version compatibility support.

@satisfied-by

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

Provides tracing SDK components for span collection and export.

@satisfied-by