Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Dec 12, 2025

Summary

Add support for continuous profiling (Profiling V2) while maintaining backward compatibility with transaction-based profiling (V1).

Changes

  • Add SentryProfileV2ChunkEvent type for profile_chunk envelope items
  • Process and merge V2 chunks by profiler_id
  • Link profiles to traces via contexts.profile.profiler_id
  • Unify V1 and V2 profiles in profilesByTraceId storage
  • Handle late-arriving chunks with re-grafting
  • Add test fixtures for manual UI testing

Testing

pnpm dev

# In another terminal:
cd packages/spotlight
node _fixtures/send_to_sidecar.cjs _fixtures/continuous_profiling/

Then open Spotlight UI, navigate to the trace, and verify:

  1. The "Profile" tab appears in trace details
  2. Profile spans are grafted into the trace tree
image

Closes #567

@vercel
Copy link

vercel bot commented Dec 12, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
spotlightjs Skipped Skipped Dec 12, 2025 2:58pm

@BYK BYK force-pushed the feat/continuous-profiling-support branch from 229eeb5 to f3272f9 Compare December 12, 2025 14:06
- Add SentryProfileV2ChunkEvent type for profile_chunk items
- Process and merge V2 chunks by profiler_id
- Link profiles to traces via contexts.profile.profiler_id
- Unify V1 and V2 profiles in profilesByTraceId storage
- Handle late-arriving chunks with re-grafting
- Add test fixtures for manual UI testing

Closes #567
@BYK BYK force-pushed the feat/continuous-profiling-support branch from f3272f9 to 2a0c3aa Compare December 12, 2025 14:06
@BYK BYK deployed to Preview December 12, 2025 14:06 — with GitHub Actions Active
@BYK BYK requested a review from betegon December 12, 2025 14:11
@BYK BYK requested a review from s1gr1d December 12, 2025 15:46
Copy link
Member

@betegon betegon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for adding support for this!

>;
};

export type SentryProfileV2ChunkEvent = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're not sharing types between server and UI right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so but we can? Should we?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so but we can? Should we?

Comment on lines +154 to +165
// Check if there's an existing transaction with this profiler_id that needs re-grafting
// This handles the case where profile chunks arrive AFTER the transaction
let traceToUpdate: string | undefined;
let activeThreadId: string | undefined;
for (const evt of eventsById.values()) {
if (isTraceEvent(evt)) {
const txn = evt as SentryTransactionEvent;
const profileCtx = txn.contexts?.profile as { profiler_id?: string } | undefined;
if (profileCtx?.profiler_id === chunk.profiler_id) {
traceToUpdate = txn.contexts.trace.trace_id;
activeThreadId = txn.contexts.trace.data?.["thread.id"] as string | undefined;
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! We talked about that, the profiler_id connects it to the transaction 👍

@BYK BYK merged commit 3bc6908 into main Dec 22, 2025
20 checks passed
@BYK BYK deleted the feat/continuous-profiling-support branch December 22, 2025 17:59
BYK pushed a commit that referenced this pull request Dec 23, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @spotlightjs/[email protected]

### Minor Changes

- Add support for continuous profiling (Profiling V2)
([#1202](#1202))

- Add self-documenting CLI commands with per-command help support
([#1206](#1206))

Each CLI command now provides its own metadata (short description,
usage, detailed help, and examples). The main help output is generated
dynamically from this metadata, and users can get detailed help for
specific commands via `spotlight help <command>` or `spotlight <command>
--help`.

### Patch Changes

- Remove dead code
([#1214](#1214))

- Fix profile visualization issues in trace views:
([#1203](#1203))

- Update frame colors to use vibrant, high-contrast colors for better
visibility
    -   Add custom nanovis palette for Spotlight's dark theme
    -   Fix sunburst center text showing bytes instead of sample counts
    -   Fix treemap visibility with proper color contrast

- added support for AI SDK v2 in AI Mode
([#1216](#1216))

- updated the empty pages of traces and envelopes
([#1213](#1213))

- open external links in default browser
([#1212](#1212))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

Add support for continuous profiling

4 participants