Skip to main content
InterviewHubPRO
Section Overview
Q34

Question 34 of 50

Part 3: Advanced Internals, Scale & Production Quality (Senior / Lead)

68%
Software Testing & QA (50 Qs)•Part 3: Advanced Internals, Scale & Production Quality (Senior / Lead)

Observability-Driven Testing: Asserting on OpenTelemetry Traces.

senior LevelCode ExampleTesting

In Simple Words: Traditional tests assert on HTTP status and response JSON, but miss background side effects (e.g., did the service emit the correct distributed tracing spans or publish an audit log?):

  • Trace-Based Testing (Tracetest):
    • Uses OpenTelemetry trace graphs as test assertions:
    typescript
    // Assert that processing an order created a child database span and Kafka publish span
    expect(trace.spans).toIncludeSpanWithAttributes({
      'db.system': 'postgresql',
      'messaging.system': 'kafka',
      'order.status': 'COMPLETED'
    });