Allow overriding the ID generator (event_id / trace_id / span_id) for snapshot-restored runtimes such as AgentCore Runtime V2
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 活発
- 技術スタック
- aws, node.js, typescript
調査の方向性
Start in packages/core/src/utils/misc.ts and trace how uuid4(), generateTraceId(), and generateSpanId() feed event, trace, and span IDs through the Node SDK. Compare the proposed client-level and uuid4-level approaches, including capture return values and beforeSend behavior; done requires an agreed API that consistently covers the requested ID paths.
索引モデルが issue の本文から書いたものです。
説明
Problem Statement
We run a Node.js service on Amazon Bedrock AgentCore Runtime, platform version V2. On V2 every new instance is restored from a single memory snapshot of an already-initialized process instead of booting from scratch (the same model as Lambda SnapStart, but without restore hooks). Anything the SDK computed or cached before the snapshot is shared by every restored instance.
This breaks the uniqueness of the IDs the SDK generates:
uuid4()(packages/core/src/utils/misc.ts) usescrypto.randomUUID(). In Node,randomUUID()serves UUIDs from a 128-entry entropy cache (lib/internal/crypto/random.js,kBatchSize = 128).Sentry.init()already consumes entries from that cache (everyScopeconstructor callsgenerateTraceId()), so the snapshot contains a partially consumed cache. After a restore, the first ~125uuid4()calls return the same values on every instance.- Once the cache is exhausted it is refilled from OpenSSL's DRBG, whose state is also in the snapshot and only reseeds after 256 requests or 1 hour (OpenSSL 3.x defaults). So the window is not just the cache; within the first hour after a runtime is created or updated, restored instances keep producing identical IDs.
event_id,trace_id(generateTraceId) andspan_id(generateSpanId) all come fromuuid4().
Observed effect: the first error captured on each restored instance has the same event_id. Sentry keeps only the first event with a given ID and drops the others as duplicate, so an error that hits N freshly started instances shows up as a single event. Trace and span IDs collide the same way, so distributed traces from different instances are merged.
We have verified the same mechanism empirically for other ID sources in the same environment (20 instances restored concurrently, first request on 19 of them produced only 3 distinct random values from crypto.randomBytes).
Nothing in the SDK can detect a restore, so this is not something the SDK can fix on its own. What is missing is a supported way to plug in our own ID source. Today:
beforeSendcan rewriteevent.event_idand the envelope uses the rewritten ID, butcaptureException()/captureEvent()still return the original ID (hintWithEventId.event_id), solastEventId()and user-feedback linking point at an ID that was never stored.hint.event_idworks for manual captures but not for errors captured by integrations.- There is no way at all to influence
trace_id/span_idgeneration.
SDK: @sentry/node 10.70.0 (the relevant code is unchanged on main), Node.js 24.
Solution Brainstorm
An SDK option to override the ID generator, applied to event_id, trace_id and span_id alike, for example:
Sentry.init({
// called for every event_id / trace_id / span_id; must return 32 hex chars
idGenerator: () => readFromDevUrandom(16).toString('hex'),
});
or, at a lower level, letting uuid4() consult a client-level override instead of always using crypto.randomUUID().
For snapshot-restored runtimes the only entropy source in Node that is reseeded on restore is the kernel CRNG, i.e. reading /dev/urandom directly (AWS documents os.urandom() as the safe source for AgentCore V2). With such a hook we could route all Sentry IDs through it. A smaller improvement that would already help would be to make beforeSend's rewritten event_id flow back into the captureException return value, but that still leaves tracing IDs uncovered.
Additional Context
- AgentCore Runtime V2 guidance on snapshot restore and randomness: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-v2-optimize.html
- Lambda SnapStart uniqueness guidance (same problem class): https://docs.aws.amazon.com/lambda/latest/dg/snapstart-uniqueness.html
- Node's
randomUUIDentropy cache: https://github.com/nodejs/node/blob/main/lib/internal/crypto/random.js - Related report we filed against the OpenTelemetry AWS distro for its
Math.random()-based trace/span IDs: https://github.com/aws-observability/aws-otel-js-instrumentation/issues/561
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
- 主要言語
- TypeScript
- スター
- 8.7k
- フォーク
- 1.9k
- 平均マージ
- 1日 15時間
- マージ済み PR(30日)
- 523
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-javascript のほかの issue
-
Next.js: basePath is concatenated onto absolute router.push hrefs, corrupting navigation transaction names対応中かも @Lms24 が 3 日前に担当しました。 オープンBrowser Bug Next.js Traces
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
getsentry/sentry-javascript#24672 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
getsentry/sentry-javascript#24200 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
javascript Task
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
getsentry/sentry-javascript#24134 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Cloudflare Workers javascript Tests
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsentry/sentry-javascript#24051 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Bug Bun javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
getsentry/sentry-javascript#24045 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
getsentry/sentry-javascript の issue をすべて見る
似ている issue
-
check:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Fission-AI/OpenSpec#1986 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
nestjs/docs.nestjs.com#3554 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
publicodes/publicodes#868 ·
-
namespace operations
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
EclipseFdn/open-vsx.org#13488 ·
メンテナーはふだん 2 日以内に返信