Gate server SDK overhead in CI and reduce per-request cost under span streaming
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- express, node.js, typescript
- 領域
- backend, performance, testing
研究方向
Start with server-utils/server-subscription.ts, core/src/tracing/trace.ts, core/src/tracing/spans/captureSpan.ts, and core/src/tracing/spans/spanBuffer.ts; the proposal identifies these paths and the relevant sampling and buffering behavior. First inspect the existing dev-packages CI suites and the tests around these tracing paths. Done means stable counter based regression coverage and measured changes to sampling, span capture, and buffering that preserve propagation and sent data; this spans several subsystems and needs project familiarity.
由索引模型根據 Issue 內容生成。
描述
Server SDK overhead has no regression gate. The timing-based node-overhead-gh-action was removed as too flaky (#20246). Kiln (#23302) compares versions on demand, but nothing runs on PRs. Regressions such as #24820 (CPU up from 10.56 to 10.74+) are found by users and are hard to bisect afterwards.
Now that span streaming is the default, a few per-request and per-span paths cost noticeably more than they need to. Local measurements on Node 24.21, using an in-process fetch against an http server so client and server instrumentation both run:
| Setup | Time per request | Scope clones per request | spanStart per request |
|---|---|---|---|
| No SDK | 0.056 ms | 0 | 0 |
init() without tracesSampleRate |
0.088 ms | 4 | 0 |
tracesSampleRate: 0 |
0.130 ms | 6 | 2 |
tracesSampleRate: 1 |
0.183 ms | 6 | 2 |
Proposal
-
A CI gate based on counts, not wall-clock time. Add a
dev-packagessuite that records stable counters for a few scenarios (raw http, express, a span-heavy loop):- scope clones per request
spanStartper request- bytes retained per buffered trace after
gc() - modules loaded by
require('@sentry/node') - heap after N requests, to catch leaks
It should fail when a counter grows past a small threshold. Timings stay informational only. The point is to avoid the flakiness that got the old action removed.
-
A cheaper sampled-out path. A request that is sampled out still costs about 70% as much as a sampled one.
- The http server subscription builds the full attribute set (headers, URL parsing, filtering) before any sampling decision (
server-utilsserver-subscription.ts). - An unsampled root still becomes a full
SentrySpan(core/src/tracing/trace.ts,sampleSpan→new SentrySpan) and emitsspanStart.
When no
tracesSamplerorbeforeSamplinghook is registered, the decision depends only ontracesSampleRate, the parent decision andsampleRand, so it can be made first. On "drop", skip building attributes and return a non-recording span. That span must still record the dropped-span outcome and keep propagation working. With a sampler registered, behavior stays as it is. - The http server subscription builds the full attribute set (headers, URL parsing, filtering) before any sampling decision (
-
Less work per span in
captureSpan. Under streaming this runs on every span end. It callsgetCombinedScopeData(copying the breadcrumb and event-processor arrays and deep-merging request data) andspanToJSON(segmentSpan)for every child (core/src/tracing/spans/captureSpan.ts). However,applyCommonSpanAttributesonly reads user, attributes, contexts and the segment's name and id. A narrow merge plus direct reads would give the same output. -
A bounded span buffer.
SpanBuffer.add(core/src/tracing/spans/spanBuffer.ts) creates one bucket and onesetTimeoutper trace. It caps size per trace but has no global cap. Each buffered span keeps its segment span alive, along with that span's scopes and request data. Locally, about 7 KB was retained per trace, and 20k buffered traces held about 141 MB until they were flushed. Proposed: global limits on buffered traces and bytes (flush the oldest bucket when reached), one shared unref'd interval instead of per-trace timers, and optionally dropping scopes and request data from the segment span once it ends.
None of these change public API or the data that is sent. Related: #15861.
- 主要語言
- TypeScript
- 星號
- 8.8k
- 分支
- 1.9k
- 平均合併
- 1 天 8 小時
- 30 天內合併 PR
- 744
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
getsentry/sentry-javascript 的其他 Issue
-
AWS Lambda Waiting for: Product Owner
難度 1/5 1 小時以內 新手友好度 82/100
getsentry/sentry-javascript#26910 · 1 則留言 ·
維護者通常 1 天內回覆
-
Only create Nuxt database and storage spans when there is a parent span可能重新可做 關聯的 PR 已關閉且未合併。 未關閉Improvement Nuxt
難度 2/5 1-3 小時 新手友好度 83/100
getsentry/sentry-javascript#25805 · 3 則留言 ·
維護者通常 1 天內回覆
-
Only create Cloudflare storage and D1 db spans when there is a parent span可能重新可做 關聯的 PR 已關閉且未合併。 未關閉Cloudflare Workers Improvement Spans
難度 2/5 1-3 小時 新手友好度 78/100
getsentry/sentry-javascript#25804 · 1 則留言 ·
維護者通常 1 天內回覆
-
Core Feature: Typescript Meta: Breaking
難度 2/5 1-3 小時 新手友好度 65/100
getsentry/sentry-javascript#25286 · 2 則留言 ·
維護者通常 1 天內回覆
-
javascript
難度 2/5 1-3 小時 新手友好度 75/100
getsentry/sentry-javascript#24200 · 2 則留言 ·
維護者通常 1 天內回覆
查看 getsentry/sentry-javascript 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
garrytan/gbrain#10437 · 1 則留言 ·
維護者通常 1 天內回覆
-
Bedrock "Too many tokens" throttle is not auto-retried, unlike "Too many requests"可能已有人在做 @acmerfight 今天認領。 未關閉untriaged
難度 2/5 1-3 小時 新手友好度 78/100
earendil-works/pi#12573 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
agentes-chat/agentes-chat#1506 ·
維護者通常 1 天內回覆
-
comp/desktop desktop/files os/windows P2 type/perf
難度 2/5 1-3 小時 新手友好度 80/100
NousResearch/hermes-agent#160359 ·
維護者通常 1 天內回覆
-
Missing repro Platform: Android
難度 2/5 1-3 小時 新手友好度 76/100
software-mansion/react-native-reanimated#11554 · 1 則留言 ·
維護者通常 1 天內回覆