HomeRoadmapsObservability Day 1
Observability-Driven QE Track Β· Day 1 Β· 20 min

OpenTelemetry & W3C TraceContext Propagation
Observability-Driven QE Sprint β€” Day 1

Master the W3C TraceContext specification (traceparent and tracestate), header parsing, and distributed context propagation across asynchronous Node.js microservice boundaries.

⚑ Runtime: Node.js 22 LTS Β· VitestπŸ›‘οΈ Observability & Distributed Systems QE Architect
OpenTelemetryW3C TraceContexttraceparentAsyncLocalStorageContext Propagation
About this lab

You are the Observability & Distributed Systems QE Architect. In modern microservice architectures, failures and latencies occur in the async seams between services. Testing HTTP status codes is insufficient: quality engineers must assert that distributed context flows faithfully across network boundaries using standard W3C traceparent headers.

Interactive Lab Tool

πŸ”¬ OpenTelemetry Trace Waterfall & Assertion Simulator

Standard Async Distributed Trace (Healthy)
W3C TraceContext Header:Spec: RFC W3C Trace-Context
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
Version: 00
Trace ID: 4bf92f3577...
Parent Span ID: 00f067aa0ba9
Sampled Flag: 01 (Active)
Span Hierarchy (Timeline: 0ms β†’ 165ms)Duration
POST /checkoutapi-gateway
165ms
OrderService.CreateOrderorder-service
120ms
PaymentService.Chargepayment-service
75ms
SELECT stock FROM inventorydb-inventory
50ms
Selected Span Metadata
Span Name: POST /checkout
Service: api-gateway
Duration: 165ms
Status: OK
Live Trace Assertion Rule
All spans recorded statusCode: OK (0 errors detected).PASS
πŸ“¦Sample Codebase & Working Solution (Day 1)Available Now
View on GitHub

The official reference codebase for Day 1 is hosted in the repository. Clone the repository and navigate to tests/day1-otel-context.spec.ts to run the working solution.

Git Clone β€” Working Solution
git clone https://github.com/777abhi/observability-qe-roadmap.git
cd observability-qe-roadmap/tests/day1-otel-context.spec.ts
🏭Production Context & Enterprise Implementation
πŸ’‘ Why We Are Doing This: Distributed traces break when developers miss passing W3C headers across thread or queue hops. Automated trace context tests prevent observability blindness in production.
🏒 Real-World Production Usecase: Verifying API Gateways, gRPC proxies, and Kafka event producers propagate traceparent headers downstream without altering traceId.
βš™οΈ How Implemented in Production: W3C TraceContext RFC compliance parser and AsyncLocalStorage context holder with 100% Vitest coverage.
Phase 1

Validate W3C Header Format & Propagation

Inspect how W3C traceparents are structured and tested in the standalone repository.

Step 1.1: Clone and Run Day 1 Tests
Terminal β€” Setup Day 1 Lab
git clone https://github.com/777abhi/observability-qe-roadmap.git
cd observability-qe-roadmap
npm install
npm run test:day1
Step 1.2: Sample Codebase & Working Solution (Day 1)
src/context/w3cTraceContext.ts
export class W3CTraceContext {
  private static readonly TRACEPARENT_REGEX = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/i;

  static parseTraceParent(header: string | null | undefined): W3CTraceParent | null {
    if (!header || typeof header !== 'string') return null;
    const match = this.TRACEPARENT_REGEX.exec(header.trim());
    if (!match) return null;

    const [, version, traceId, parentId, traceFlags] = match;
    if (version.toLowerCase() === 'ff') return null; // Forbidden by W3C
    if (/^0+$/.test(traceId) || /^0+$/.test(parentId)) return null;

    return {
      version,
      traceId: traceId.toLowerCase(),
      parentId: parentId.toLowerCase(),
      traceFlags: traceFlags.toLowerCase(),
      isSampled: (parseInt(traceFlags, 16) & 1) === 1,
    };
  }
}
Day 1 Key Learnings
  • Mastered W3C TraceContext standards and regex parsing (version-traceId-parentId-flags).
  • Propagated distributed trace headers across async boundaries using Node.js AsyncLocalStorage.
  • Verified valid traceparent structure and rejection of invalid/forbidden versions like ff or all-zeros.

🧠 Knowledge Check

According to the official W3C Trace-Context specification, which condition makes a traceparent header strictly invalid?