usePublishQueuesTimeSeriesQuery.tsx 811 B

12345678910111213141516171819202122232425262728
  1. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  2. import {useSpanMetricsSeries} from 'sentry/views/insights/common/queries/useDiscoverSeries';
  3. import type {Referrer} from 'sentry/views/insights/queues/referrers';
  4. import type {SpanMetricsProperty} from 'sentry/views/insights/types';
  5. type Props = {
  6. referrer: Referrer;
  7. destination?: string;
  8. enabled?: boolean;
  9. };
  10. const yAxis: SpanMetricsProperty[] = ['avg(span.duration)', 'spm()'];
  11. export function usePublishQueuesTimeSeriesQuery({enabled, destination, referrer}: Props) {
  12. const search = new MutableSearch('span.op:queue.publish');
  13. if (destination) {
  14. search.addFilterValue('messaging.destination.name', destination, false);
  15. }
  16. return useSpanMetricsSeries(
  17. {
  18. yAxis,
  19. search,
  20. enabled,
  21. },
  22. referrer
  23. );
  24. }