docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A simple Express.js application that processes requests through multiple asynchronous middleware stages with proper distributed tracing support.
Build an Express.js application with a middleware pipeline that performs asynchronous operations at each stage. The application should be instrumented with OpenTelemetry to enable distributed tracing, ensuring trace context flows correctly through all async operations.
Create an Express server that:
/process endpoint that uses the middleware chainImplement three middleware functions that execute in sequence:
Each middleware should:
The final handler should return a JSON response with:
/process returns status 200 with a JSON response containing "success" status @test/process @test/**
* Creates and configures an Express application with OpenTelemetry instrumentation.
*
* @returns {Express.Application} Configured Express app with tracing enabled
*/
function createApp() {
// IMPLEMENTATION HERE
}
/**
* Authentication middleware that performs async user validation.
*
* @param {Express.Request} req - Express request object
* @param {Express.Response} res - Express response object
* @param {Function} next - Express next middleware function
*/
async function authMiddleware(req, res, next) {
// IMPLEMENTATION HERE
}
/**
* Data enrichment middleware that fetches additional data asynchronously.
*
* @param {Express.Request} req - Express request object
* @param {Express.Response} res - Express response object
* @param {Function} next - Express next middleware function
*/
async function enrichmentMiddleware(req, res, next) {
// IMPLEMENTATION HERE
}
/**
* Business logic handler that processes the request with async operations.
*
* @param {Express.Request} req - Express request object
* @param {Express.Response} res - Express response object
*/
async function processHandler(req, res) {
// IMPLEMENTATION HERE
}
module.exports = {
createApp,
authMiddleware,
enrichmentMiddleware,
processHandler
};Provides automatic instrumentation for Express.js applications enabling distributed tracing and context propagation through middleware chains and async operations.
Web application framework for building the HTTP server and middleware pipeline.
Core OpenTelemetry API for accessing trace context and spans.
OpenTelemetry SDK for Node.js providing tracing infrastructure.