How it works
- Your test framework creates a session automatically (the pytest
varianzfixture, the JUnitVarianzSessionparameter, the Vitest/Playwright fixtures, Go’svarianztest.NewSession). The session ID is a 32-character hex string. - The test inserts stages into the session.
- The test triggers the service, passing the ID in the
x-varianz-idheader (HTTP) or metadata key (gRPC). - Inside the service, an interceptor extracts the ID and holds it in the request context; every VPoint the request touches applies that session’s stages.
- When the service calls other services, it forwards the header, so the session follows the request through the whole graph.
- When the test ends, the session is destroyed and its stages are removed automatically.
x-varianz-id header see no stages at all — the default plan runs on a fast path. That’s what makes it safe to keep VPoints in production code.
Propagation is a one-time setup
Steps 4 and 5 — extracting the ID and forwarding it downstream — are a one-time setup per service, after which every future VPoint works automatically. The mechanics differ by language and framework (context vars in Python,AsyncLocalStorage in Node, context.Context in Go, a request-scoped carrier in Java), and OpenTelemetry Baggage can carry it for you if you already run OTel.
Copy-paste interceptors for every supported framework are in Propagate sessions. Set this up before writing tests: a missing forwarding hop is the most common reason a stage “mysteriously” doesn’t apply.
Sessions synchronize before the test runs
Inserting a stage is asynchronous — services subscribed to the registry receive it a moment later. Test SDKs expose a barrier,await_sync_or_fail(timeout) / awaitSyncOrFail(timeout), that blocks until every currently-connected subscriber confirms it received your stages. Always call it between inserting stages and triggering the service. Details and edge cases (including what “0 of 0 subscribers” means) are in How tests work.
Security
Only test infrastructure should be able to set session IDs. At your API gateway, strip or override incomingx-varianz-id (and OTel baggage) headers from the public internet, and validate the format (32-char hex) where you accept it internally.