Skip to content

feat(sdk): Share portable telemetry processing across consumers - #1374

Draft
MathurAditya724 wants to merge 7 commits into
mainfrom
codex/shared-telemetry-sdk
Draft

MathurAditya724 wants to merge 7 commits into
mainfrom
codex/shared-telemetry-sdk

Conversation

@MathurAditya724

@MathurAditya724 MathurAditya724 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Spotlight's UI and SDK now share envelope normalization, trace assembly, logs, profiles, database/resource summaries, AI extraction, and web-vitals calculations. Server consumers get the same processing that powers the UI, including streamed spans from #1372. Moving the package to Toolkit remains separate work.

createTelemetryStore() from @spotlightjs/spotlight/sdk/core accepts parsed envelopes on the frontend or server. createTelemetryPipeline() from /sdk/node adds serialized payload decoding and bounded asynchronous decompression. The released /sdk buffer helpers retain their existing behavior. Domain code moves out of the UI behind compatibility reexports, while the Node decoder no longer imports the Spotlight server.

Both factories expose a shared TelemetryReader, immutable snapshots, typed receipts, delivery IDs, ordered batches, cancellation, a drain barrier, and change notifications. Receipts distinguish processing from retention and include counts, a revision, and machine-readable diagnostics. Query/resource summaries are compact by default; includeSpans: true retrieves detail. Reads support time/order/limit filters, and paged cursors are bound to the query and snapshot revision. Explicit versioned serializers preserve trace graphs, maps, and sets for JSON/tool consumers.

The Node input methods are ingestPayload() and getDecodedPayload(); both factories also accept ingestEnvelope(). Pending ingestion, envelope bytes, retained history, decoded output, and enrichment time are bounded. The decompressor enforces its output limit before a compressed payload can expand without bounds. Parsed and payload writes share one Node admission queue, and cancellation during retention replay restores the previously committed history.

Start review with the public contracts, core lifecycle, shared reader/serializers, and Node adapter. Retention defaults to 500 envelopes with a 64 MiB serialized-envelope budget. Eviction rebuilds derived state for correctness; immutable event/log/envelope copies and derived reads are reused, but large profiles still increase replay cost. The README documents exact limits, missing-record behavior, retry identity, lazy batch-copy semantics, JSON formats, and lifecycle behavior.

Regression coverage includes server/frontend/UI parity, binary/opaque items, malformed boundaries, compressed output limits, mixed-method admission and drain ordering, cancellation/reset during enrichment and eviction, byte retention, stale cursors, JSON graph references, and immutable UI reads. CI now checks the built public declarations and executes the server/frontend/React example contracts and lifecycle walkthrough after building.

The shared package and Sentry Local adoption are proposed in Toolkit #1690. After its first @sentry/telemetry release, Spotlight can replace this extraction with the published dependency. Both PRs use createTelemetryStore and createTelemetryPipeline; the Toolkit PR adds independently reusable Local inspection models.

@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
spotlightjs Skipped Skipped Oct 28, 2026 9:59am UTC

Request Review

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ Patch coverage is 83.80% (1764 of 2105 changed executable lines covered; target 80%).
Project statement coverage is 73.02% (up 17.53 percentage points from base (fdda0de) to head (487d336)).

Changed files with executable lines (53)
File Patch coverage Changed executable lines
packages/spotlight/src/telemetry/ai/vercelAISDK.ts 24.40% 51/209 covered; missed: 86, 87, 88, 89, 92, 121, 122, 123, 124, 126, 129, 147, 149, 153, 157, 158, 161, 165, 173, 174, 176, 177, 178, 179, 180, 181, 186, 187, 188, 189, 190, 191, 196, 197, 201, 208, 209, 211, 213, 214, 215, 218, 220, 223, 224, 225, 226, 228, 229, 234, 236, 238, 239, 245, 246, 247, 248, 249, 253, 257, 258, 261, 265, 266, 268, 269, 271, 272, 274, 286, 287, 289, 291, 293, 296, 300, 301, 303, 304, 305, 306, 307, 312, 315, 316, 317, 318, 323, 324, 325, 326, 331, 332, 333, 334, 338, 339, 342, 343, 347, 348, 349, 350, 354, 355, 356, 357, 363, 365, 366, 367, 368, 374, 376, 377, 378, 379, 381, 382, 387, 389, 393, 394, 395, 396, 398, 402, 404, 410, 412, 414, 415, 416, 419, 420, 421, 424, 425, 426, 429, 430, 431, 436, 438, 439, 441, 442, 448, 449, 450, 451, 453, 457, 458, 459, 460, 462, 466
packages/spotlight/src/telemetry/index.ts 97.20% 313/322 covered; missed: 117, 118, 275, 344, 360, 361, 362, 446, 510; partial branches: 26, 92, 116, 122, 128, 146, 155, 219, 235, 255, 269, 271, 346, 350, 351, 358, 359, 368, 372, 373, 378, 395, 411, 414, 417, 431, 435, 445, 468, 475, 499, 507
packages/spotlight/src/telemetry/ai/genAI.ts 91.95% 137/149 covered; missed: 145, 150, 157, 169, 208, 211, 230, 271, 279, 317, 318, 343; partial branches: 134, 149, 153, 166, 177, 189, 207, 210, 221, 222, 234, 236, 249, 255, 258, 278, 285, 316, 326, 341, 348, 350
packages/spotlight/src/sdk/node.ts 96.55% 224/232 covered; missed: 148, 179, 206, 229, 232, 242, 270, 275; partial branches: 77, 79, 137, 164, 165, 198, 227, 228, 231, 241, 251, 253, 268, 269, 274, 318, 319, 323, 332, 337, 354, 362, 402, 407, 412
packages/spotlight/src/telemetry/reader.ts 91.67% 132/144 covered; missed: 205, 232, 240, 267, 269, 286, 294, 310, 323, 336, 349, 388; partial branches: 104, 171, 253, 266, 268, 293, 347, 348, 351, 359, 380, 387
packages/spotlight/src/telemetry/store/slices/envelopesSlice.ts 88.89% 80/90 covered; missed: 22, 75, 86, 87, 88, 113, 148, 149, 150, 160; partial branches: 19, 21, 26, 56, 74, 83, 85, 95, 98, 108, 112, 122, 138
packages/spotlight/src/telemetry/store/slices/eventsSlice.ts 91.74% 111/121 covered; missed: 31, 118, 119, 120, 186, 187, 190, 191, 192, 194; partial branches: 30, 39, 41, 107, 114, 155, 184, 185, 207, 219, 230, 232, 260
packages/spotlight/src/telemetry/data/profiles.ts 85.87% 79/92 covered; missed: 66, 69, 70, 71, 72, 75, 95, 178, 179, 186, 187, 191, 192; partial branches: 44, 94, 133, 160, 177, 185, 190
packages/spotlight/src/telemetry/envelope/userAgent.ts 39.13% 9/23 covered; missed: 16, 17, 22, 23, 28, 29, 43, 45, 46, 47, 48, 52, 53, 56; partial branches: 6, 11, 15, 21, 27, 34
packages/spotlight/src/telemetry/store/utils/profileProcessor.ts 0.00% 0/16 covered; missed: 25, 26, 29, 30, 33, 35, 37, 38, 42, 47, 50, 57, 62, 69, 70, 74
packages/spotlight/src/telemetry/store/utils/traceProcessor.ts 92.73% 51/55 covered; missed: 35, 91, 123, 174; partial branches: 34, 39, 55, 90, 122, 129, 138, 139, 173, 183
packages/spotlight/src/telemetry/serialization.ts 91.04% 61/67 covered; missed: 100, 101, 102, 103, 104, 135; partial branches: 36, 39, 42, 43, 49, 50, 99
packages/spotlight/src/ui/telemetry/store/store.ts 80.36% 45/56 covered; missed: 12, 64, 81, 82, 87, 88, 89, 90, 125, 126, 132; partial branches: 20, 27
packages/spotlight/src/telemetry/store/slices/subscriptionsSlice.ts 16.67% 2/12 covered; missed: 14, 15, 16, 17, 18, 20, 21, 22, 23, 24
packages/spotlight/src/telemetry/utils/traces.ts 75.68% 28/37 covered; missed: 70, 71, 72, 76, 78, 79, 80, 84, 86
packages/spotlight/src/telemetry/utils/sdkToPlatform.ts 100.00% 10/10 covered; partial branches: 5, 7, 8, 9, 10, 11, 12, 13
packages/spotlight/src/telemetry/ai/aiLibraries.ts 73.91% 17/23 covered; missed: 19, 46, 53, 54, 58, 59; partial branches: 45
packages/spotlight/src/telemetry/envelope/source.ts 90.32% 28/31 covered; missed: 56, 61, 148; partial branches: 55, 60, 82, 147
packages/spotlight/src/telemetry/utils/webVitals.ts 95.35% 41/43 covered; missed: 86, 126; partial branches: 14, 85, 98, 125, 157
packages/spotlight/src/telemetry/internal/readonly.ts 88.89% 32/36 covered; missed: 30, 33, 36, 39; partial branches: 18, 46
packages/spotlight/src/telemetry/logger.ts 50.00% 5/10 covered; missed: 8, 9, 13, 14, 22
packages/spotlight/src/telemetry/store/slices/sharedSlice.ts 50.00% 5/10 covered; missed: 8, 9, 11, 14, 15
packages/spotlight/src/telemetry/store/utils/logProcessor.ts 85.71% 12/14 covered; missed: 18, 26; partial branches: 17, 25, 30
packages/spotlight/src/telemetry/store/slices/sdksSlice.ts 94.44% 17/18 covered; missed: 21; partial branches: 18, 19, 20
packages/spotlight/src/telemetry/envelope/codec.ts 96.23% 51/53 covered; missed: 108, 109; partial branches: 101
packages/spotlight/src/telemetry/store/slices/logsSlice.ts 40.00% 2/5 covered; missed: 8, 11, 12
packages/spotlight/src/telemetry/store/utils/spanProcessor.ts 100.00% 29/29 covered; partial branches: 16, 39, 83
packages/spotlight/src/telemetry/store/utils/traceInitializer.ts 80.00% 4/5 covered; missed: 10; partial branches: 9, 14
packages/spotlight/src/server/parser/processEnvelope.ts 75.00% 3/4 covered; missed: 12; partial branches: 18
packages/spotlight/src/telemetry/store/slices/profilesSlice.ts 50.00% 2/4 covered; missed: 13, 17
packages/spotlight/src/telemetry/store/utils.ts 50.00% 2/4 covered; missed: 7, 8
packages/spotlight/src/telemetry/utils/profileUtils.ts 100.00% 10/10 covered; partial branches: 8, 10
packages/spotlight/src/telemetry/selectors/ai.ts 100.00% 4/4 covered; partial branches: 11
packages/spotlight/src/telemetry/selectors/resources.ts 100.00% 12/12 covered; partial branches: 23
packages/spotlight/src/telemetry/selectors/spans.ts 100.00% 14/14 covered; partial branches: 15
packages/spotlight/src/telemetry/store/utils/profileChunkProcessor.ts 100.00% 44/44 covered; partial branches: 109
packages/spotlight/src/telemetry/capabilities.ts 100.00% 1/1 covered
packages/spotlight/src/telemetry/constants/performance.ts 100.00% 1/1 covered
packages/spotlight/src/telemetry/constants/sentry.ts 100.00% 8/8 covered
packages/spotlight/src/telemetry/envelope/payload.ts 100.00% 8/8 covered
packages/spotlight/src/telemetry/internal/engine.ts 100.00% 3/3 covered
packages/spotlight/src/telemetry/internal/envelopes.ts 100.00% 15/15 covered
packages/spotlight/src/telemetry/internal/results.ts 100.00% 6/6 covered
packages/spotlight/src/telemetry/internal/retention.ts 100.00% 7/7 covered
packages/spotlight/src/telemetry/selectors/database.ts 100.00% 4/4 covered
packages/spotlight/src/telemetry/selectors/profiles.ts 100.00% 15/15 covered
packages/spotlight/src/telemetry/selectors/webVitals.ts 100.00% 6/6 covered
packages/spotlight/src/telemetry/store/helpers.ts 100.00% 2/2 covered
packages/spotlight/src/telemetry/store/slices/tracesSlice.ts 100.00% 3/3 covered
packages/spotlight/src/telemetry/utils/sentry.ts 100.00% 6/6 covered
packages/spotlight/src/telemetry/uuid.ts 100.00% 6/6 covered
packages/spotlight/src/ui/telemetry/components/events/EventContexts.tsx 100.00% 2/2 covered
packages/spotlight/src/ui/telemetry/data/sentryEventsContext.tsx 100.00% 4/4 covered
Coverage diff
@@            Coverage Diff             @@
##          main     #1374       +/-##
==========================================
+ Coverage    55.49%    73.02%   +17.53%
==========================================
  Files           81       118       +37
  Tracked lines      2586      3603     +1017
  Branches      1889      2801      +912
==========================================
+ Hits          1439      2656     +1217
+ Misses        1147       947      -200
- Partials       186       295      +109

Generated by Coverage Action

Comment thread packages/spotlight/src/sdk/node.ts Outdated
Comment thread packages/spotlight/src/sdk/node.ts Fixed
Comment thread packages/spotlight/src/telemetry/envelope/codec.ts
Use telemetry store and pipeline names, explicit envelope and payload batch methods, and decoded history options. Preserve live retention and immutable snapshots for deeply nested span graphs.

Co-Authored-By: Codex <noreply@openai.com>
Accept cross-realm byte inputs, preserve log-only traces and resource size metadata, and keep self-parented spans visible. Update the executable examples to the telemetry naming.

Co-Authored-By: Codex <noreply@openai.com>

This branch was successfully deployed

1 active deployment
Preview — 487d3365 Deployed Oct 28, 2026 by MathurAditya724 via Build #2452
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants