traceMetaQuery.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. export type TraceMetaQueryChildrenProps = BaseTraceChildrenProps & {
  13. meta: TraceMeta | null;
  14. };
  15. type QueryProps = Omit<TraceRequestProps, 'eventView'> & {
  16. children: (props: TraceMetaQueryChildrenProps) => React.ReactNode;
  17. };
  18. function TraceMetaQuery({
  19. traceId,
  20. start,
  21. end,
  22. statsPeriod,
  23. children,
  24. ...props
  25. }: QueryProps) {
  26. if (!traceId) {
  27. return (
  28. <Fragment>
  29. {children({
  30. isLoading: false,
  31. error: null,
  32. meta: null,
  33. })}
  34. </Fragment>
  35. );
  36. }
  37. const eventView = makeEventView({start, end, statsPeriod});
  38. return (
  39. <GenericDiscoverQuery<TraceMeta, {}>
  40. route={`events-trace-meta/${traceId}`}
  41. getRequestPayload={getTraceRequestPayload}
  42. eventView={eventView}
  43. {...props}
  44. >
  45. {({tableData, ...rest}) => {
  46. return children({
  47. meta: tableData,
  48. ...rest,
  49. });
  50. }}
  51. </GenericDiscoverQuery>
  52. );
  53. }
  54. export default TraceMetaQuery;