mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import omit from 'lodash/omit';
|
|
|
|
import {defined} from 'sentry/utils';
|
|
import type {
|
|
DiscoverQueryProps,
|
|
GenericChildrenProps,
|
|
} from 'sentry/utils/discover/genericDiscoverQuery';
|
|
import GenericDiscoverQuery from 'sentry/utils/discover/genericDiscoverQuery';
|
|
|
|
import type {SpanExample} from './types';
|
|
|
|
type SpanExamplesProps = {
|
|
spanGroup: string;
|
|
spanOp: string;
|
|
maxExclusiveTime?: string;
|
|
minExclusiveTime?: string;
|
|
};
|
|
|
|
type RequestProps = DiscoverQueryProps & SpanExamplesProps;
|
|
|
|
export type ChildrenProps = Omit<GenericChildrenProps<SpanExamplesProps>, 'tableData'> & {
|
|
examples: SpanExample[] | null;
|
|
};
|
|
|
|
type Props = RequestProps & {
|
|
children: (props: ChildrenProps) => React.ReactNode;
|
|
};
|
|
|
|
function getSuspectSpanPayload(props: RequestProps) {
|
|
const {spanOp, spanGroup, minExclusiveTime, maxExclusiveTime} = props;
|
|
const span =
|
|
defined(spanOp) && defined(spanGroup) ? `${spanOp}:${spanGroup}` : undefined;
|
|
const payload = defined(span)
|
|
? {span, min_exclusive_time: minExclusiveTime, max_exclusive_time: maxExclusiveTime}
|
|
: {};
|
|
const additionalPayload = omit(props.eventView.getEventsAPIPayload(props.location), [
|
|
'field',
|
|
]);
|
|
return {...payload, ...additionalPayload};
|
|
}
|
|
|
|
function SuspectSpansQuery(props: Props) {
|
|
return (
|
|
<GenericDiscoverQuery<SpanExample[], SpanExamplesProps>
|
|
route="events-spans"
|
|
getRequestPayload={getSuspectSpanPayload}
|
|
{...omit(props, 'children')}
|
|
>
|
|
{({tableData, ...rest}) => {
|
|
return props.children({
|
|
examples: tableData ?? null,
|
|
...rest,
|
|
});
|
|
}}
|
|
</GenericDiscoverQuery>
|
|
);
|
|
}
|
|
|
|
export default SuspectSpansQuery;
|