Skip to content

feat(trace-view): Add cache lifecycle section to span details - #126180

Merged
s1gr1d merged 5 commits into
masterfrom
sig/cachelifecycle-component
Oct 2, 2026
Merged

s1gr1d merged 5 commits into
masterfrom
sig/cachelifecycle-component

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Adds a "Cache Lifecycle" section to the span details drawer for cache.get and cache.put spans. It shows the entry as a timeline: filled, hit/miss (this span), expires.

On reads, it resolves the cache_origin span link, fetches the fill span, and shows the origin transaction, source file, and put duration, with a button that opens the origin span.

Notes for review:

image

hit

image

miss

image

fill

image |

Linear: https://linear.app/getsentry/issue/JSSDK-28/add-cache-lifecycle-experience-to-the-product

@s1gr1d
s1gr1d requested a review from a team as a code owner October 1, 2026 14:52
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 1, 2026
@s1gr1d
s1gr1d requested a review from chargome October 1, 2026 14:56
}): CacheOrigin {
const {data, isLoading} = useTraceItemDetails({
traceItemId: link?.itemId ?? '',
projectId: node.value.project_id.toString(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The useCacheOrigin hook incorrectly uses the current span's project ID to fetch linked cache spans, causing lookups to fail silently for cross-project traces.
Severity: MEDIUM

Suggested Fix

The TraceItemResponseLink type should be augmented to include the projectId of the linked span. This projectId should then be used in the useTraceItemDetails hook when fetching the origin span's details, ensuring the API call is directed to the correct project.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
static/app/views/performance/traceDetails/traceDrawer/details/span/eapSections/cacheLifecycle.tsx#L140

Potential issue: In traces involving multiple projects, the `useCacheOrigin` hook fails
to fetch details for linked cache spans from other projects. The hook incorrectly uses
the current span's project ID (`node.value.project_id`) for the API request to fetch the
origin span's details. Since the backend API validates that the span belongs to the
provided project ID, the request for a cross-project span fails silently. This results
in the UI not displaying crucial information like the transaction name, source file, or
fill duration for the cache origin, degrading the feature's usefulness in microservice
architectures.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's a known limitation. We don't store the project ID on the span link. There's a todo in the code

@nsdeschenes nsdeschenes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code looks good, two small nits to take a peek at 🙏

* - A registered referrer for this query (sentry/snuba/referrer.py). Until
* then, borrow the log-details referrer.
*/
function useCacheOrigin({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we remove this hook, and move the request directly into the component, this hook isn't doing a whole lot, just a tiny wrapper for a single call site.

Comment on lines +261 to +263
if (!props.organization.features.includes('performance-trace-cache-lifecycle')) {
return null;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we move this check up one level to where the cache lifecycle is being added, imo that's a bit clearer than having it hidden away a bit in here.

Comment on lines +392 to +394
<Button size="xs" onClick={openOriginSpan} busy={origin.isLoading}>
{t('Open origin span')}
</Button>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

note: we have a <LinkButton> component for this, which should be preferred over a Button with a navigate so that users can open them in new tabs etc.

@s1gr1d
s1gr1d merged commit 7575a95 into master Oct 2, 2026
79 checks passed
@s1gr1d
s1gr1d deleted the sig/cachelifecycle-component branch October 2, 2026 10:46

This branch was successfully deployed

1 active deployment
Preview — 9d822f13 Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants