Skip to content

Commit 10144ca

Browse files
Abdullah KhanAbdullah Khan
Abdullah Khan
authored and
Abdullah Khan
committed
feat(new-trace): Rendering new copy only if the trace timestamp is <= 2minutes old
1 parent 4e2434f commit 10144ca

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

static/app/views/performance/newTraceDetails/trace.spec.tsx

+38-2
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,12 @@ describe('trace view', () => {
909909
expect(await screen.findByText(/we failed to load your trace/i)).toBeInTheDocument();
910910
});
911911

912-
it('renders empty state', async () => {
912+
it('renders empty state for successfully ingested trace', async () => {
913+
// set timestamp to 3 minutes ago
914+
const threeMinutesAgoInSeconds = Math.floor(
915+
new Date(Date.now() - 3 * 60 * 1000).getTime() / 1000
916+
);
917+
913918
mockPerformanceSubscriptionDetailsResponse();
914919
mockTraceResponse({
915920
body: {
@@ -921,12 +926,43 @@ describe('trace view', () => {
921926
mockTraceTagsResponse();
922927
mockEventsResponse();
923928

924-
render(<TraceView />, {router});
929+
window.location.search = `?timestamp=${threeMinutesAgoInSeconds.toString()}`;
930+
render(<TraceView />, {
931+
router,
932+
});
925933
expect(
926934
await screen.findByText(/trace does not contain any data/i)
927935
).toBeInTheDocument();
928936
});
929937

938+
it('renders empty state for yet to be ingested trace', async () => {
939+
// set timestamp to 1 minute ago
940+
const oneMinuteAgoInSeconds = Math.floor(
941+
new Date(Date.now() - 1 * 60 * 1000).getTime() / 1000
942+
);
943+
944+
mockPerformanceSubscriptionDetailsResponse();
945+
mockTraceResponse({
946+
body: {
947+
transactions: [],
948+
orphan_errors: [],
949+
},
950+
});
951+
mockTraceMetaResponse();
952+
mockTraceTagsResponse();
953+
mockEventsResponse();
954+
955+
window.location.search = `?timestamp=${oneMinuteAgoInSeconds.toString()}`;
956+
render(<TraceView />, {
957+
router,
958+
});
959+
expect(
960+
await screen.findByText(
961+
/We could still be ingesting this trace. Please wait a few seconds and refresh./i
962+
)
963+
).toBeInTheDocument();
964+
});
965+
930966
describe('pageload', () => {
931967
it('scrolls to trace root', async () => {
932968
mockQueryString('?node=trace-root');

static/app/views/performance/newTraceDetails/traceWaterfallState.tsx

+15-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import styled from '@emotion/styled';
44
import useFeedbackWidget from 'sentry/components/feedback/widget/useFeedbackWidget';
55
import LoadingIndicator from 'sentry/components/loadingIndicator';
66
import {t} from 'sentry/locale';
7+
import {useTraceQueryParams} from 'sentry/views/performance/newTraceDetails/useTraceQueryParams';
78

89
function TraceLoading() {
910
return (
@@ -43,13 +44,22 @@ function TraceEmpty() {
4344
const linkref = useRef<HTMLAnchorElement>(null);
4445
const feedback = useFeedbackWidget({buttonRef: linkref});
4546

47+
const traceQueryParams = useTraceQueryParams();
48+
const timestamp = traceQueryParams.timestamp;
49+
50+
// Traces take longer to ingest than spans, we could click on the id of a span
51+
// and be navigated to a trace that doesn't contain any data yet. We add a 2
52+
// minute buffer to account for this.
53+
const message =
54+
timestamp && new Date(timestamp * 1000) > new Date(Date.now() - 2 * 60 * 1000)
55+
? t(
56+
'We could still be ingesting this trace. Please wait a few seconds and refresh.'
57+
)
58+
: t('This trace does not contain any data.');
59+
4660
return (
4761
<LoadingContainer animate>
48-
<div>
49-
{t(
50-
'We could still be ingesting this trace. Please wait a few seconds and refresh.'
51-
)}
52-
</div>
62+
<div>{message}</div>
5363
<div>
5464
{t('Seeing this often? Send us ')}
5565
{feedback ? (

0 commit comments

Comments
 (0)