CLI tracing: proxy exporter so CLI spans ship through the server
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:
- Write a custom OTel
SpanExporterthat serializes completed spans and sends them to the server via RPC - Add a server-side RPC endpoint (e.g.,
ReportSpans) that receives span data and forwards it to the server's configured collector - Replace the CLI's env-var-gated
SetupTracingcall 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.