Restate (tracing)
Restate (tracing)
Restate is a durable execution system with Python Service, Virtual Object, and Workflow handlers. Respan uses Restate’s invocation_context_managers extension point to create one span around each handler invocation attempt.
Set up Respan
Create an account at platform.respan.ai and grab an API key.
Run npx @respan/cli setup to set up with your coding agent.
Example project
Setup
Initialize and register handlers
Initialize Respan before decorating Restate handlers. The instrumentor adds its invocation context manager when handlers are registered.
Run Restate
Start a local Restate server, register the Python endpoint, and invoke the handler:
You can also use the official Restate server and CLI binaries from Restate releases if the npm launcher does not provide a binary for your platform.
View your trace
Open the Traces page to inspect each invocation’s handler and durable-execution context.
What gets traced
When Restate provides them, the adapter also records scope, limit key, idempotency key, service metadata, and handler metadata. The request is deserialized through the handler’s configured Restate serde.
Restate invocation IDs are mapped to Respan trace groups. Virtual Object and Workflow keys are mapped to thread identifiers.
Handler results
Restate’s invocation context managers surround execution but do not receive the handler’s serialized return value. Successful spans therefore record a completion status, not an invented response body. Failed spans record the real exception class, message, and status code exposed by Restate, including custom TerminalError codes.
This behavior intentionally differs from integrations whose native hooks expose a return value.
Replay and content controls
The adapter records whether Restate reports the invocation as replaying; it traces the actual invocation attempt exposed to the context manager.
Disable deserialized request capture when request bodies may contain sensitive data:
Service, handler, invocation, replay, key, scope, idempotency, and status fields remain available.
Lifecycle
The instrumentor patches handler registration on Service, VirtualObject, and Workflow. Handlers registered before activation are not retrofitted. Each service object receives at most one Respan context manager, and existing user-provided context managers are preserved.
activate() and deactivate() are reference-counted. Call respan.shutdown() during service shutdown to flush pending spans and restore the registration methods.