Skip to main content
REST API

Distributed Tracing

TraceRequestValidateHard

What you will learn

  • Parse W3C traceparent (version-traceId-spanId-flags) and validate format strictly
  • Propagate trace context across service boundaries โ€” a broken chain kills observability
  • Use trace IDs to correlate API test failures with server logs โ€” your debugging superpower

Description

Propagate trace IDs across service calls.

Test Scenario

const traceId = 'trace-' + Date.now();
const response = await request.get('/api/v1/tracing', {
  headers: { 'X-Request-ID': traceId }
});
expect(response.headers()['x-request-id']).toBe(traceId);
Endpoint/api/v1/tracing

Testing Tips

  • โ€ขSend X-Request-ID header
  • โ€ขCheck X-Request-ID in response
  • โ€ขVerify trace spans in logs
// Playwright API Testing - REST
import { test, expect } from '@playwright/test';
test('REST API request', async ({ request }) => {
const response = await request.get('/api/v1/resource');
expect(response.ok()).toBeTruthy();
expect(response.status()).toBe(200);
const data = await response.json();
expect(data).toBeDefined();
});

Challenge ID: rest-tracing

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/v1/tracing

Press Enter to send