This example demonstrates distributed tracing across a fictional multi-tier system:
┌──────────┐ ┌─────────────┐ ┌─────────────────┐ ┌────────────┐
│ Client │────▶│ Restate │────▶│ Greeter Service │────▶│ Downstream │
│ App │ │ Server │ │ (SDK/Node) │ │ Service │
└──────────┘ └─────────────┘ └─────────────────┘ └────────────┘
│ │ │ │
│ │ │ │
▼ ▼ ▼ ▼
┌────────────────────────────────────────────────────────────────────────┐
│ Jaeger │
└────────────────────────────────────────────────────────────────────────┘
What gets traced:
- Client App - Creates the root span and injects W3C trace context into the Restate request
- Restate Server - Receives trace context, emits spans for ingress requests and handler invocations
- Greeter Service - SDK handler using
@restatedev/restate-sdk-opentelemetrythat creates spans per attempt, perctx.runand propagates context to downstream calls - Downstream Service - Receives and logs the propagated trace headers
- Node.js 18+
- Docker (for Jaeger)
docker run -d --name jaeger \
-p 4317:4317 \
-p 16686:16686 \
jaegertracing/all-in-one:latestJaeger UI will be available at http://localhost:16686
npm installnpx @restatedev/restate-server --tracing-endpoint http://localhost:4317npm run downstreamnpm run servicenpx @restatedev/restate deployments register http://localhost:9080npm run client AliceAfter running the client, you'll see output like:
Root Trace ID: abc123...
View in Jaeger: `http://localhost:16686/trace/abc123...`
Open the Jaeger link to see the complete distributed trace spanning all four components.
The trace will show spans from all four services:
- client-app: The root
client-requestspan - Greeter: Restate server spans for ingress, invoke, and journal operations
- restate-greeter-service: Custom
Greeter.greetspan with events - downstream-service:
handle-requestspan (may show errors due to 50% failure rate)
src/client.ts- Client app that initiates traced requestssrc/restate-service.ts- Restate Greeter service with OpenTelemetry instrumentationsrc/downstream.ts- HTTP server with tracing and random failure rate