Issues
MIR-707

CLI tracing: proxy exporter so CLI spans ship through the server

Done public

Context

MIR-703 added OTel tracing to the deploy/build path. The CLI creates spans (deploy, create_deployment, upload, finalize) and the server creates spans for each build phase. Trace context propagates via RPC headers so everything connects into a single trace.

However, the CLI currently requires its own OTEL_EXPORTER_OTLP_ENDPOINT env var to export spans — an independent, direct relationship with the collector. This isn't a great story: you'd need to configure tracing on both the server and every CLI invocation.

Proposal

Build a proxy exporter so CLI spans ship through the existing RPC connection to the server, which re-exports them to its collector. The CLI already talks to the server — no new connection needed.

The approach:

  1. Write a custom OTel SpanExporter that serializes completed spans and sends them to the server via RPC
  2. Add a server-side RPC endpoint (e.g., ReportSpans) that receives span data and forwards it to the server's configured collector
  3. Replace the CLI's env-var-gated SetupTracing call with this proxy exporter, initialized from the existing RPC client

This is a common pattern for mobile/browser clients where the frontend can't (or shouldn't need to) talk to the collector directly.

The CLI-side span creation code from MIR-703 stays exactly the same — we're just swapping which exporter it uses. The span hierarchy (CLI root → RPC → server phases) is already wired up correctly.

Result

miren deploy produces end-to-end traces automatically when the server has tracing configured. No CLI-side env vars needed.