getsentry / getsentry/sentry-javascript

Stream finished spans to stdout for local debugging

Offen
#21,086 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Core Feature javascript
Vorherrschende Sprache
TypeScript
Sterne
8.7k
Forks
1.8k
Ø Merge
1 T. 17 Std.
Gemergte PRs (30 T.)
515

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.