getsentry / getsentry/sentry-javascript

Stream finished spans to stdout for local debugging

未关闭
#21,086 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
Core Feature javascript
主要语言
TypeScript
星标
8.7k
派生
1.8k
平均合并
1 天 17 小时
30 天内合并 PR
515

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。