Skip to main content

Combining Sandboxes

Testing a single microservice in isolation is great, but modern applications are rarely built that way. SandboxMesh lets you combine multiple, completely isolated sandboxes into a single testing session—without writing custom routing logic or deploying heavy duplicate stacks.

The secret is the standard W3C baggage HTTP header.

How it works

When traffic enters your cluster, your routing layer inspects the baggage header for the sandbox key.

Because the baggage header can carry multiple comma-separated values, you can pass several sandbox IDs in a single request. As the request flows through your architecture, different services will independently route to their respective preview environments based on the IDs present.

This allows you to instantly test complex scenarios like:

  • A preview frontend talking to a preview backend API.
  • A new API endpoint triggering a sandboxed background worker.
  • Injecting a single sandboxed service into a flow while all other hops remain on your stable baseline.

Example request

Imagine you have a sandboxed frontend (sbx-front123) and a sandboxed backend (sbx-back456). You can test them together by providing both IDs:

bash
curl \
-H "baggage: sandbox=sbx-front123_sbx-back456" \
https://api.example.com

In this flow:

  1. SandboxMesh sees both IDs in the baggage header.
  2. The initial route matches sbx-front123 and directs traffic to your preview frontend.
  3. As long as your application propagates the header downstream, the next internal request will match sbx-back456 and land safely on your preview backend.

Header Propagation

For multi-service composition to work smoothly, your application must propagate the incoming baggage header to its outbound downstream requests.

The Easy Way: OpenTelemetry

If your stack uses OpenTelemetry, you're likely already done. W3C baggage propagation is usually handled automatically by standard OpenTelemetry instrumentation.

Manual Propagation

If you aren't using an automated tracing framework, simply copy the incoming baggage header from the request object and attach it to the outgoing HTTP client call.

For a deep dive into keeping context alive across queues, asynchronous jobs, and complex service hops, read our guide on Context Propagation.

Best Practices

  • Keep it Deterministic: When chaining IDs, use stable separators like _ or - to keep debugging simple.
  • Verify Baseline First: If a downstream service isn't hitting your sandbox, verify that the baggage header is successfully propagating in your baseline environment before debugging the mesh.
  • Stick to the Defaults: We highly recommend using the default baggage header to ensure maximum compatibility with modern tracing tools.