Repository navigation
feat(trace-view): Add cache lifecycle section to span details - #126180
Conversation
| }): CacheOrigin { | ||
| const {data, isLoading} = useTraceItemDetails({ | ||
| traceItemId: link?.itemId ?? '', | ||
| projectId: node.value.project_id.toString(), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
That's a known limitation. We don't store the project ID on the span link. There's a todo in the code
nsdeschenes
left a comment
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
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.
| if (!props.organization.features.includes('performance-trace-cache-lifecycle')) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
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.
…ecycle` (#126184) Needed for this: #126180 Flagpole (merge afterwards): getsentry/sentry-options-automator#9985
| <Button size="xs" onClick={openOriginSpan} busy={origin.isLoading}> | ||
| {t('Open origin span')} | ||
| </Button> |
There was a problem hiding this comment.
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.
Needed for "Trace Lifecycle" view that shows trace data of a linked span Related: #126180 Linear: https://linear.app/getsentry/issue/JSSDK-30/snuba-register-referrer-for-cache-item-query
Adds a "Cache Lifecycle" section to the span details drawer for
cache.getandcache.putspans. It shows the entry as a timeline: filled, hit/miss (this span), expires.On reads, it resolves the
cache_originspan 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:
organizations:performance-trace-cache-lifecycle(registered in feat(trace-view): Add flagorganizations:performance-trace-cache-lifecycle#126184).cache.*attributes and its span links. The only extra request fetches the linked fill span viauseTraceItemDetails.TODO(cache)comment: typed link attributes are dropped until fix(explore): Unwrap typed span link attribute values in trace item details #125749 is merged (single untyped link is treated as the origin) and the origin fetch borrows the log-details referrer.hit
miss
fill
Linear: https://linear.app/getsentry/issue/JSSDK-28/add-cache-lifecycle-experience-to-the-product