|
@@ -1,4 +1,4 @@
|
|
|
-import {Fragment, useMemo, useState} from 'react';
|
|
|
+import {Fragment, useMemo} from 'react';
|
|
|
import type {Location} from 'history';
|
|
|
|
|
|
import ButtonBar from 'sentry/components/buttonBar';
|
|
@@ -12,7 +12,6 @@ import {t} from 'sentry/locale';
|
|
|
import type {EventTransaction, Organization} from 'sentry/types';
|
|
|
import {trackAnalytics} from 'sentry/utils/analytics';
|
|
|
import EventView from 'sentry/utils/discover/eventView';
|
|
|
-import {TraceFullDetailedQuery} from 'sentry/utils/performance/quickTrace/traceFullQuery';
|
|
|
import TraceMetaQuery, {
|
|
|
type TraceMetaQueryChildrenProps,
|
|
|
} from 'sentry/utils/performance/quickTrace/traceMetaQuery';
|
|
@@ -26,6 +25,7 @@ import {useLocation} from 'sentry/utils/useLocation';
|
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
|
import {useParams} from 'sentry/utils/useParams';
|
|
|
import useProjects from 'sentry/utils/useProjects';
|
|
|
+import {useTrace} from 'sentry/views/performance/newTraceDetails/useTrace';
|
|
|
|
|
|
import Breadcrumb from '../breadcrumb';
|
|
|
|
|
@@ -46,19 +46,19 @@ export function TraceView() {
|
|
|
|
|
|
const traceSlug = params.traceSlug?.trim() ?? '';
|
|
|
|
|
|
- const dateSelection = useMemo(() => {
|
|
|
- const queryParams = normalizeDateTimeParams(location.query, {
|
|
|
+ const queryParams = useMemo(() => {
|
|
|
+ const normalizedParams = normalizeDateTimeParams(location.query, {
|
|
|
allowAbsolutePageDatetime: true,
|
|
|
});
|
|
|
- const start = decodeScalar(queryParams.start);
|
|
|
- const end = decodeScalar(queryParams.end);
|
|
|
- const statsPeriod = decodeScalar(queryParams.statsPeriod);
|
|
|
+ const start = decodeScalar(normalizedParams.start);
|
|
|
+ const end = decodeScalar(normalizedParams.end);
|
|
|
+ const statsPeriod = decodeScalar(normalizedParams.statsPeriod);
|
|
|
|
|
|
- return {start, end, statsPeriod};
|
|
|
+ return {start, end, statsPeriod, useSpans: 1};
|
|
|
}, [location.query]);
|
|
|
|
|
|
- const _traceEventView = useMemo(() => {
|
|
|
- const {start, end, statsPeriod} = dateSelection;
|
|
|
+ const traceEventView = useMemo(() => {
|
|
|
+ const {start, end, statsPeriod} = queryParams;
|
|
|
|
|
|
return EventView.fromSavedQuery({
|
|
|
id: undefined,
|
|
@@ -72,48 +72,34 @@ export function TraceView() {
|
|
|
end,
|
|
|
range: statsPeriod,
|
|
|
});
|
|
|
- }, [dateSelection, traceSlug]);
|
|
|
+ }, [queryParams, traceSlug]);
|
|
|
|
|
|
- const [_limit, _setLimit] = useState<number>();
|
|
|
- // const _handleLimithange = useCallback((newLimit: number) => {
|
|
|
- // setLimit(newLimit);
|
|
|
- // }, []);
|
|
|
+ const trace = useTrace();
|
|
|
|
|
|
return (
|
|
|
<SentryDocumentTitle title={DOCUMENT_TITLE} orgSlug={organization.slug}>
|
|
|
<Layout.Page>
|
|
|
<NoProjectMessage organization={organization}>
|
|
|
- <TraceFullDetailedQuery
|
|
|
- type="spans"
|
|
|
+ <TraceMetaQuery
|
|
|
location={location}
|
|
|
orgSlug={organization.slug}
|
|
|
traceId={traceSlug}
|
|
|
- start={dateSelection.start}
|
|
|
- end={dateSelection.end}
|
|
|
- statsPeriod={dateSelection.statsPeriod}
|
|
|
+ start={queryParams.start}
|
|
|
+ end={queryParams.end}
|
|
|
+ statsPeriod={queryParams.statsPeriod}
|
|
|
>
|
|
|
- {trace => (
|
|
|
- <TraceMetaQuery
|
|
|
+ {metaResults => (
|
|
|
+ <TraceViewContent
|
|
|
+ status={trace.status}
|
|
|
+ trace={trace.data}
|
|
|
+ traceSlug={traceSlug}
|
|
|
+ organization={organization}
|
|
|
location={location}
|
|
|
- orgSlug={organization.slug}
|
|
|
- traceId={traceSlug}
|
|
|
- start={dateSelection.start}
|
|
|
- end={dateSelection.end}
|
|
|
- statsPeriod={dateSelection.statsPeriod}
|
|
|
- >
|
|
|
- {metaResults => (
|
|
|
- <TraceViewContent
|
|
|
- traceSplitResult={trace?.traces}
|
|
|
- traceSlug={traceSlug}
|
|
|
- organization={organization}
|
|
|
- location={location}
|
|
|
- traceEventView={_traceEventView}
|
|
|
- metaResults={metaResults}
|
|
|
- />
|
|
|
- )}
|
|
|
- </TraceMetaQuery>
|
|
|
+ traceEventView={traceEventView}
|
|
|
+ metaResults={metaResults}
|
|
|
+ />
|
|
|
)}
|
|
|
- </TraceFullDetailedQuery>
|
|
|
+ </TraceMetaQuery>
|
|
|
</NoProjectMessage>
|
|
|
</Layout.Page>
|
|
|
</SentryDocumentTitle>
|
|
@@ -124,35 +110,41 @@ type TraceViewContentProps = {
|
|
|
location: Location;
|
|
|
metaResults: TraceMetaQueryChildrenProps;
|
|
|
organization: Organization;
|
|
|
+ status: 'pending' | 'resolved' | 'error' | 'initial';
|
|
|
+ trace: TraceSplitResults<TraceFullDetailed> | null;
|
|
|
traceEventView: EventView;
|
|
|
traceSlug: string;
|
|
|
- traceSplitResult: TraceSplitResults<TraceFullDetailed> | null;
|
|
|
};
|
|
|
|
|
|
function TraceViewContent(props: TraceViewContentProps) {
|
|
|
- const rootEvent = props.traceSplitResult?.transactions?.[0];
|
|
|
const {projects} = useProjects();
|
|
|
+
|
|
|
const tree = useMemo(() => {
|
|
|
- if (!props.traceSplitResult) {
|
|
|
+ if (props.status === 'pending') {
|
|
|
return TraceTree.Loading({
|
|
|
project_slug: projects?.[0]?.slug ?? '',
|
|
|
event_id: props.traceSlug,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- return TraceTree.FromTrace(props.traceSplitResult);
|
|
|
- }, [props.traceSlug, props.traceSplitResult, projects]);
|
|
|
+ if (props.trace) {
|
|
|
+ return TraceTree.FromTrace(props.trace);
|
|
|
+ }
|
|
|
+
|
|
|
+ return TraceTree.Empty();
|
|
|
+ }, [props.traceSlug, props.trace, props.status, projects]);
|
|
|
|
|
|
const traceType = useMemo(() => {
|
|
|
- if (tree.type === 'loading') {
|
|
|
+ if (props.status !== 'resolved' || !tree) {
|
|
|
return null;
|
|
|
}
|
|
|
return TraceTree.GetTraceType(tree.root);
|
|
|
- }, [tree]);
|
|
|
+ }, [props.status, tree]);
|
|
|
|
|
|
+ const root = props.trace?.transactions?.[0];
|
|
|
const rootEventResults = useApiQuery<EventTransaction>(
|
|
|
[
|
|
|
- `/organizations/${props.organization.slug}/events/${rootEvent?.project_slug}:${rootEvent?.event_id}/`,
|
|
|
+ `/organizations/${props.organization.slug}/events/${root?.project_slug}:${root?.event_id}/`,
|
|
|
{
|
|
|
query: {
|
|
|
referrer: 'trace-details-summary',
|
|
@@ -161,10 +153,7 @@ function TraceViewContent(props: TraceViewContentProps) {
|
|
|
],
|
|
|
{
|
|
|
staleTime: 0,
|
|
|
- enabled: !!(
|
|
|
- props.traceSplitResult?.transactions &&
|
|
|
- props.traceSplitResult.transactions.length > 0
|
|
|
- ),
|
|
|
+ enabled: !!(props.trace?.transactions && props.trace.transactions.length > 0),
|
|
|
}
|
|
|
);
|
|
|
|
|
@@ -209,14 +198,14 @@ function TraceViewContent(props: TraceViewContentProps) {
|
|
|
rootEventResults={rootEventResults}
|
|
|
metaResults={props.metaResults}
|
|
|
organization={props.organization}
|
|
|
- traces={props.traceSplitResult}
|
|
|
+ traces={props.trace}
|
|
|
/>
|
|
|
<Trace trace={tree} trace_id={props.traceSlug} />
|
|
|
<TraceFooter
|
|
|
rootEventResults={rootEventResults}
|
|
|
organization={props.organization}
|
|
|
location={props.location}
|
|
|
- traces={props.traceSplitResult}
|
|
|
+ traces={props.trace}
|
|
|
traceEventView={props.traceEventView}
|
|
|
/>
|
|
|
<TraceDetailPanel />
|