-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(trace-waterfall): Add warning for old traces #104630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nsdeschenes
merged 11 commits into
master
from
nd/exp-645/feat-trace-waterfall-add-alert-for-old-traces
Dec 12, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
93f66ec
:sparkles: Add in new trace warning when trace is older than 30 days
nsdeschenes b517435
:white_check_mark: Add in tests
nsdeschenes 5d6f6e7
:necktie: Add in new alert to the trace details page
nsdeschenes 097be2c
:sparkles: Add table arg to getExploreUrl
nsdeschenes a40efbf
:recycle: Refactor to use getExploreUrl helper
nsdeschenes 5db5001
:white_check_mark: Update tests
nsdeschenes be4e7b3
:necktie: Pass table to query params
nsdeschenes 1c57a63
:necktie: Rework how we determine the title, and add project to query
nsdeschenes 1f94d1c
:white_check_mark: Update tests
nsdeschenes 6947018
:rotating_light: Make knip happy
nsdeschenes c96970f
:rewind: Revert back to using project page filter selection
nsdeschenes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
.../app/views/performance/newTraceDetails/traceTypeWarnings/partialTraceDataWarning.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import {OrganizationFixture} from 'sentry-fixture/organization'; | ||
|
|
||
| import {render, screen} from 'sentry-test/reactTestingLibrary'; | ||
|
|
||
| import {TraceTree} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree'; | ||
| import { | ||
| makeEAPSpan, | ||
| makeEAPTrace, | ||
| } from 'sentry/views/performance/newTraceDetails/traceModels/traceTreeTestUtils'; | ||
|
|
||
| import {PartialTraceDataWarning} from './partialTraceDataWarning'; | ||
|
|
||
| describe('PartialTraceDataWarning', () => { | ||
| describe('when the trace is older than 30 days', () => { | ||
| beforeAll(() => { | ||
| jest.useFakeTimers().setSystemTime(new Date(2025, 0, 31)); | ||
| }); | ||
|
|
||
| afterAll(() => { | ||
nsdeschenes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| jest.useRealTimers(); | ||
| }); | ||
|
|
||
| it('should render warning', () => { | ||
| const organization = OrganizationFixture(); | ||
| const start = new Date('2024-01-01T00:00:00Z').getTime() / 1e3; | ||
|
|
||
| const eapTrace = makeEAPTrace([ | ||
| makeEAPSpan({ | ||
| op: 'http.server', | ||
| start_timestamp: start, | ||
| end_timestamp: start + 2, | ||
| children: [makeEAPSpan({start_timestamp: start + 1, end_timestamp: start + 4})], | ||
| }), | ||
| ]); | ||
|
|
||
| render( | ||
| <PartialTraceDataWarning | ||
| logs={[]} | ||
| timestamp={start} | ||
| tree={TraceTree.FromTrace(eapTrace, {replay: null, meta: null, organization})} | ||
| />, | ||
| {organization} | ||
| ); | ||
|
|
||
| expect(screen.getByText('Partial Trace Data:')).toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByText( | ||
| 'Trace may be missing spans since the age of the trace is older than 30 days' | ||
| ) | ||
| ).toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByRole('link', {name: 'Search similar traces in the past 24 hours'}) | ||
| ).toBeInTheDocument(); | ||
|
|
||
| const queryString = encodeURIComponent('is_transaction:true span.op:http.server'); | ||
| expect( | ||
| screen.getByRole('link', {name: 'Search similar traces in the past 24 hours'}) | ||
| ).toHaveAttribute( | ||
| 'href', | ||
| `/organizations/${organization.slug}/explore/traces/?mode=samples&project=1&query=${queryString}&statsPeriod=24h&table=trace` | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('when the trace is younger than 30 days', () => { | ||
| beforeAll(() => { | ||
| jest.useFakeTimers().setSystemTime(new Date(2025, 0, 1)); | ||
| }); | ||
|
|
||
| afterAll(() => { | ||
| jest.useRealTimers(); | ||
| }); | ||
|
|
||
| it('should not render the warning', () => { | ||
| const organization = OrganizationFixture(); | ||
| const start = new Date('2025-01-01T00:00:00Z').getTime() / 1e3; | ||
|
|
||
| const eapTrace = makeEAPTrace([ | ||
| makeEAPSpan({ | ||
| op: 'http.server', | ||
| start_timestamp: start, | ||
| end_timestamp: start + 2, | ||
| children: [makeEAPSpan({start_timestamp: start + 1, end_timestamp: start + 4})], | ||
| }), | ||
| ]); | ||
|
|
||
| render( | ||
| <PartialTraceDataWarning | ||
| logs={[]} | ||
| timestamp={start} | ||
| tree={TraceTree.FromTrace(eapTrace, {replay: null, meta: null, organization})} | ||
| />, | ||
| {organization} | ||
| ); | ||
|
|
||
| expect(screen.queryByText('Partial Trace Data:')).not.toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.queryByText( | ||
| 'Trace may be missing spans since the age of the trace is older than 30 days' | ||
| ) | ||
| ).not.toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.queryByRole('link', {name: 'Search similar traces in the past 24 hours'}) | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
| }); | ||
| }); | ||
103 changes: 103 additions & 0 deletions
103
static/app/views/performance/newTraceDetails/traceTypeWarnings/partialTraceDataWarning.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| import {useMemo} from 'react'; | ||
| import moment from 'moment-timezone'; | ||
|
|
||
| import {Alert} from '@sentry/scraps/alert'; | ||
| import {Link} from '@sentry/scraps/link'; | ||
| import {Text} from '@sentry/scraps/text'; | ||
|
|
||
| import {t, tct} from 'sentry/locale'; | ||
| import {MutableSearch} from 'sentry/utils/tokenizeSearch'; | ||
| import useOrganization from 'sentry/utils/useOrganization'; | ||
| import usePageFilters from 'sentry/utils/usePageFilters'; | ||
| import {Mode} from 'sentry/views/explore/contexts/pageParamsContext/mode'; | ||
| import type {OurLogsResponseItem} from 'sentry/views/explore/logs/types'; | ||
| import {getExploreUrl} from 'sentry/views/explore/utils'; | ||
| import {getRepresentativeTraceEvent} from 'sentry/views/performance/newTraceDetails/traceApi/utils'; | ||
| import type {TraceTree} from 'sentry/views/performance/newTraceDetails/traceModels/traceTree'; | ||
|
|
||
| interface PartialTraceDataWarningProps { | ||
| logs: OurLogsResponseItem[] | undefined; | ||
| timestamp: number | undefined; | ||
| tree: TraceTree; | ||
| } | ||
|
|
||
| export function PartialTraceDataWarning({ | ||
| logs, | ||
| timestamp, | ||
| tree, | ||
| }: PartialTraceDataWarningProps) { | ||
| const organization = useOrganization(); | ||
| const {selection} = usePageFilters(); | ||
|
|
||
| const rep = getRepresentativeTraceEvent(tree, logs); | ||
|
|
||
| let op = ''; | ||
| if (rep?.event) { | ||
| op = | ||
| 'transaction.op' in rep.event | ||
| ? `${rep.event?.['transaction.op']}` | ||
| : 'op' in rep.event | ||
| ? `${rep.event.op}` | ||
| : ''; | ||
| } | ||
|
|
||
| const queryString = useMemo(() => { | ||
| const search = new MutableSearch(''); | ||
| search.addFilterValue('is_transaction', 'true'); | ||
|
|
||
| if (op) { | ||
| search.addFilterValue('span.op', op); | ||
| } | ||
|
|
||
| return search.formatString(); | ||
| }, [op]); | ||
|
|
||
| if (!timestamp) { | ||
| return null; | ||
| } | ||
|
|
||
| const now = moment(); | ||
| const isTraceTooYoung = moment(timestamp * 1000).isAfter(now.subtract(30, 'days')); | ||
|
|
||
| if (isTraceTooYoung) { | ||
| return null; | ||
| } | ||
|
|
||
nsdeschenes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const projects = | ||
| typeof rep.event?.project_id === 'number' ? [rep.event?.project_id] : []; | ||
|
|
||
| const exploreUrl = getExploreUrl({ | ||
| organization, | ||
| mode: Mode.SAMPLES, | ||
| query: queryString, | ||
| table: 'trace', | ||
| selection: { | ||
| ...selection, | ||
| projects, | ||
| datetime: { | ||
| start: null, | ||
| end: null, | ||
| utc: null, | ||
| period: '24h', | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| return ( | ||
| <Alert | ||
| type="warning" | ||
| trailingItems={ | ||
| <Link to={exploreUrl}>{t('Search similar traces in the past 24 hours')}</Link> | ||
| } | ||
| > | ||
| <Text as="p"> | ||
| {tct( | ||
| '[dataCategory] Trace may be missing spans since the age of the trace is older than 30 days', | ||
| { | ||
| dataCategory: <Text bold>{t('Partial Trace Data:')}</Text>, | ||
| } | ||
| )} | ||
| </Text> | ||
| </Alert> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.