Skip to content

feat(tools): Add outputSchema to get_profile - #2023

Merged
dcramer merged 4 commits into
mainfrom
feat/structured-get-profile
Nov 5, 2026
Merged

dcramer merged 4 commits into
mainfrom
feat/structured-get-profile

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

get_profile ("Get Transaction Profile") now returns an outputSchema and schema-conforming structuredContent for the aggregated transaction flamegraph. Errors still throw.

Each frame appears once in analysis.frames. topFunctions, the hot path stack arrays and the hot path leaf values point to frames by index, so a shared parent frame isn't repeated for every hot path. Fields are mapped explicitly, and a no-leak test checks key names and a distinctive raw fixture value.

Fixes from review

  • Time breakdown: userCodeMs and libraryMs now split the main thread's sample_durations_ns by whether each sample's leaf frame is application code.
    • Before, they added up inclusive sumDuration over the top 20 frames, so they could exceed estimatedTotalMs.
    • libraryMs is estimatedTotalMs − userCodeMs, so the two always add up. A test checks this.
    • sumSelfTime isn't used, because vroom counts library children inside an app frame's self time.
  • Frame sampleCount renamed to occurrences: vroom's frame_infos.count sums node occurrences, not samples. Frame percentOfSamples is dropped. Hot paths keep sampleCount and percentOfSamples, which really are sample-based.
  • Nullable file and line: this applies to frames and to comparison changes, and the "" and 0 placeholders map to null. Both cases are tested.
  • estimatedTotalMs description: it now reads "Sampled duration across the aggregated stacks returned", because vroom keeps only the top 1000 stacks.

Tokens (o200k_base, realistic fixture, JSON vs old markdown)

Case JSON pretty JSON compact Old markdown
Analysis, focusOnUserCode=true 2433 1496 2759
Analysis, focusOnUserCode=false 3691 2264 3975
Comparison ~860 ~565 ~720

The outputSchema is 865 tokens and the description is 449. measure-tokens doesn't count the outputSchema.

Follow-up (A), known existing bug, not changed here: the comparison compares absolute sumDuration across windows of different length (7d vs 14d), so results lean toward "improvement". It should normalize by window length or sample count.

Merge note: this PR and the get_profile_details PR both touch the profile formatter. Whichever merges second must git rm both packages/mcp-core/src/tools/support/profile/formatter.ts and formatter.test.ts, then regenerate. Keeping either side's formatter breaks tsc or leaves dead code.

On rebase: regenerate toolDefinitions.json with pnpm run --filter @sentry/mcp-core generate-definitions.

Checks run with SENTRY_AUTH_TOKEN unset: generate-definitions (no diff), mcp-core tsc, full mcp-core vitest and root lint all pass. Root tsc, test and build were not run.

via @dcramer.

--

View Session [Sentry]

sentry-junior Bot and others added 3 commits November 5, 2026 19:49
Return the aggregated transaction flamegraph as structured content instead
of markdown. Frames are listed once in `analysis.frames` and referenced by
index from top functions and hot path stacks, so shared parents are not
repeated per hot path. Missing data stays a successful result, reported by
`hasCurrentData` / `hasBaselineData` with a null analysis or comparison.

Generic follow-up guidance from the old markdown (caching, N+1 review,
regression investigation, no-data troubleshooting) moves into the tool
hints. The now-unused flamegraph markdown formatters, `formatPercentage`,
and the insight icons are removed.

Co-Authored-By: David Cramer <[email protected]>
Split userCodeMs and libraryMs by the leaf frame of each main-thread sample
so they add up to estimatedTotalMs. Summing inclusive sumDuration over
nested hotspots double counted time.

Rename the frame sampleCount to occurrences and drop percentOfSamples:
vroom's frame_infos.count sums call-tree occurrences, not samples, so it can
exceed the sample count. Map the API's "" and 0 file and line placeholders
to null.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 5, 2026 8:43pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 5, 2026
Sort improvements before unchanged frames so the truncated comparison
changes list always contains a frame that matches the reported status.
@dcramer
dcramer merged commit 9eca77a into main Nov 5, 2026
34 checks passed
@dcramer
dcramer deleted the feat/structured-get-profile branch November 5, 2026 22:21
sentry-junior Bot added a commit that referenced this pull request Nov 5, 2026
#2023 landed get_profile structured output, so the profile markdown
formatter and its test have no callers left. Remove both and
regenerate tool definitions.

This branch was previously deployed

2 inactive deployments
Actions — 0f43e69c Deployed Nov 5, 2026 by sentry-junior[bot] via eval #1623
Preview — 0f43e69c Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant