getsentry / getsentry/sentry-javascript
Stream finished spans to stdout for local debugging
- Lenguaje dominante
- TypeScript
- Estrellas
- 8.7k
- Forks
- 1.8k
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 515
Descripción
## Current behavior
The SDK captures spans via OpenTelemetry and exports them to Sentry. There is no built-in way to emit span data to stdout or the local logging system at runtime.
## Gap
When building agents, most telemetry ends up in spans rather than logs. Developers currently need Spotlight (which requires a proxy/sidecar) to inspect spans locally. This is especially painful in agent-in-a-loop scenarios where the agent needs to self-debug — it has no way to see its own span data without external tooling.
## Proposed behavior
Add an opt-in mode that streams each span to stdout as it finishes, one line per span. Output should include enough context to reconstruct parentage but does not need to render a tree — spans complete at different times so tree rendering isn't practical in a streaming model.
Minimal per-line fields:
- span name
- trace ID
- span ID
- parent span ID
- duration
- status
- key attributes (e.g. `op`, `description`)
Activation options:
- `Sentry.init({ logSpans: true })`
- `SENTRY_LOG_SPANS=1` environment variable (primary ergonomic win — drop it in `.env` or `.bashrc` and every process emits span data with zero code changes)
Implementation notes:
- Must write to `process.stdout` directly, not `console.log`, to avoid recursion with console instrumentation
- Registers as an additional `SpanExporter` on the existing OTel `TracerProvider`
- Structured JSON by default for machine consumption; optional pretty format TBD
## Context
This is an exploratory idea. The primary value proposition is agents self-debugging: when you're building an agent, most of the interesting telemetry is already in spans, not logs. Giving the agent (or developer) direct stdout visibility into its own trace data — without needing Spotlight or a proxy — fills a real gap.
Raised by David Cramer.
Action taken on behalf of David Cramer.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.