traceMetaQuery.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import {Fragment} from 'react';
  2. import GenericDiscoverQuery from 'sentry/utils/discover/genericDiscoverQuery';
  3. import {
  4. BaseTraceChildrenProps,
  5. TraceMeta,
  6. TraceRequestProps,
  7. } from 'sentry/utils/performance/quickTrace/types';
  8. import {
  9. getTraceRequestPayload,
  10. makeEventView,
  11. } from 'sentry/utils/performance/quickTrace/utils';
  12. import withApi from 'sentry/utils/withApi';
  13. export type TraceMetaQueryChildrenProps = BaseTraceChildrenProps & {
  14. meta: TraceMeta | null;
  15. };
  16. type QueryProps = Omit<TraceRequestProps, 'eventView'> & {
  17. children: (props: TraceMetaQueryChildrenProps) => React.ReactNode;
  18. };
  19. function TraceMetaQuery({
  20. traceId,
  21. start,
  22. end,
  23. statsPeriod,
  24. children,
  25. ...props
  26. }: QueryProps) {
  27. if (!traceId) {
  28. return (
  29. <Fragment>
  30. {children({
  31. isLoading: false,
  32. error: null,
  33. meta: null,
  34. })}
  35. </Fragment>
  36. );
  37. }
  38. const eventView = makeEventView({start, end, statsPeriod});
  39. return (
  40. <GenericDiscoverQuery<TraceMeta, {}>
  41. route={`events-trace-meta/${traceId}`}
  42. getRequestPayload={getTraceRequestPayload}
  43. eventView={eventView}
  44. {...props}
  45. >
  46. {({tableData, ...rest}) => {
  47. return children({
  48. meta: tableData,
  49. ...rest,
  50. });
  51. }}
  52. </GenericDiscoverQuery>
  53. );
  54. }
  55. export default withApi(TraceMetaQuery);