getsentry / getsentry/sentry-javascript

Stream finished spans to stdout for local debugging

Aperta
#21,086 1 commento 1 reazione 0 assegnatari Vedi su GitHub
Core Feature javascript
Lingua principale
TypeScript
Stelle
8.7k
Fork
1.8k
Merge medio
1g 17h
PR unite (30g)
515

Descrizione

## 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.