|
@@ -1,9 +1,13 @@
|
|
|
import React from 'react';
|
|
|
|
|
|
-import GenericDiscoverQuery from 'app/utils/discover/genericDiscoverQuery';
|
|
|
+import GenericDiscoverQuery, {
|
|
|
+ DiscoverQueryProps,
|
|
|
+} from 'app/utils/discover/genericDiscoverQuery';
|
|
|
import {
|
|
|
+ BaseTraceChildrenProps,
|
|
|
+ FullQuickTrace,
|
|
|
TraceFull,
|
|
|
- TraceFullQueryChildrenProps,
|
|
|
+ TraceFullDetailed,
|
|
|
TraceRequestProps,
|
|
|
} from 'app/utils/performance/quickTrace/types';
|
|
|
import {
|
|
@@ -13,11 +17,34 @@ import {
|
|
|
} from 'app/utils/performance/quickTrace/utils';
|
|
|
import withApi from 'app/utils/withApi';
|
|
|
|
|
|
-type QueryProps = Omit<TraceRequestProps, 'eventId' | 'eventView'> & {
|
|
|
- children: (props: TraceFullQueryChildrenProps) => React.ReactNode;
|
|
|
+type AdditionalQueryProps = {
|
|
|
+ detailed?: boolean;
|
|
|
};
|
|
|
|
|
|
-function EmptyTrace({children}: Pick<QueryProps, 'children'>) {
|
|
|
+type TraceFullQueryChildrenProps<T> = BaseTraceChildrenProps &
|
|
|
+ Omit<FullQuickTrace, 'trace'> & {
|
|
|
+ /**
|
|
|
+ * The `event-trace` endpoint returns a full trace with the parent-child
|
|
|
+ * relationships. It can be flattened into a `QuickTraceEvent` if necessary.
|
|
|
+ */
|
|
|
+ trace: T | null;
|
|
|
+ };
|
|
|
+
|
|
|
+type QueryProps<T> = Omit<TraceRequestProps, 'eventView'> &
|
|
|
+ AdditionalQueryProps & {
|
|
|
+ children: (props: TraceFullQueryChildrenProps<T>) => React.ReactNode;
|
|
|
+ };
|
|
|
+
|
|
|
+function getTraceFullRequestPayload({
|
|
|
+ detailed,
|
|
|
+ ...props
|
|
|
+}: DiscoverQueryProps & AdditionalQueryProps) {
|
|
|
+ const additionalApiPayload: any = getQuickTraceRequestPayload(props);
|
|
|
+ additionalApiPayload.detailed = detailed ? '1' : '0';
|
|
|
+ return additionalApiPayload;
|
|
|
+}
|
|
|
+
|
|
|
+function EmptyTrace<T>({children}: Pick<QueryProps<T>, 'children'>) {
|
|
|
return (
|
|
|
<React.Fragment>
|
|
|
{children({
|
|
@@ -30,24 +57,24 @@ function EmptyTrace({children}: Pick<QueryProps, 'children'>) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-function TraceFullQuery({
|
|
|
+function GenericTraceFullQuery<T>({
|
|
|
traceId,
|
|
|
start,
|
|
|
end,
|
|
|
statsPeriod,
|
|
|
children,
|
|
|
...props
|
|
|
-}: QueryProps) {
|
|
|
+}: QueryProps<T>) {
|
|
|
if (!traceId) {
|
|
|
- return <EmptyTrace>{children}</EmptyTrace>;
|
|
|
+ return <EmptyTrace<T>>{children}</EmptyTrace>;
|
|
|
}
|
|
|
|
|
|
const eventView = makeEventView({start, end, statsPeriod});
|
|
|
|
|
|
return (
|
|
|
- <GenericDiscoverQuery<TraceFull, {}>
|
|
|
+ <GenericDiscoverQuery<T, AdditionalQueryProps>
|
|
|
route={`events-trace/${traceId}`}
|
|
|
- getRequestPayload={getQuickTraceRequestPayload}
|
|
|
+ getRequestPayload={getTraceFullRequestPayload}
|
|
|
beforeFetch={beforeFetch}
|
|
|
eventView={eventView}
|
|
|
{...props}
|
|
@@ -58,9 +85,8 @@ function TraceFullQuery({
|
|
|
// the client returns a empty string when the response
|
|
|
// is 204. And we want the empty string, undefined and
|
|
|
// null to be converted to null.
|
|
|
- // TODO(wmak): replace once the backend starts returning arrays
|
|
|
- // `(tableData || null)?.[0] ?? null,`
|
|
|
- trace: (tableData || null)?.[0] ?? (tableData || null),
|
|
|
+ // TODO(tonyx): update to return the entire array
|
|
|
+ trace: (tableData || null)?.[0] ?? null,
|
|
|
type: 'full',
|
|
|
...rest,
|
|
|
})
|
|
@@ -69,4 +95,14 @@ function TraceFullQuery({
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-export default withApi(TraceFullQuery);
|
|
|
+export const TraceFullQuery = withApi(
|
|
|
+ (props: Omit<QueryProps<TraceFull>, 'detailed'>) => (
|
|
|
+ <GenericTraceFullQuery<TraceFull> {...props} detailed={false} />
|
|
|
+ )
|
|
|
+);
|
|
|
+
|
|
|
+export const TraceFullDetailedQuery = withApi(
|
|
|
+ (props: Omit<QueryProps<TraceFullDetailed>, 'detailed'>) => (
|
|
|
+ <GenericTraceFullQuery<TraceFullDetailed> {...props} detailed />
|
|
|
+ )
|
|
|
+);
|