getsentry / getsentry/sentry-javascript

Stream finished spans to stdout for local debugging

Đang mở
#21,086 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
Core Feature javascript
Ngôn ngữ chính
TypeScript
Star
8.7k
Fork
1.8k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
515

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.