useQueuesTimeSeriesQuery.tsx 1001 B

123456789101112131415161718192021222324252627282930313233
  1. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  2. import {DEFAULT_QUERY_FILTER} from 'sentry/views/performance/queues/settings';
  3. import {useSpanMetricsSeries} from 'sentry/views/starfish/queries/useDiscoverSeries';
  4. import type {SpanMetricsProperty} from 'sentry/views/starfish/types';
  5. type Props = {
  6. destination?: string;
  7. enabled?: boolean;
  8. };
  9. const yAxis: SpanMetricsProperty[] = [
  10. 'avg_if(span.duration,span.op,queue.publish)',
  11. 'avg_if(span.duration,span.op,queue.process)',
  12. 'avg(messaging.message.receive.latency)',
  13. 'count_op(queue.publish)',
  14. 'count_op(queue.process)',
  15. ];
  16. export function useQueuesTimeSeriesQuery({enabled, destination}: Props) {
  17. const mutableSearch = new MutableSearch(DEFAULT_QUERY_FILTER);
  18. if (destination) {
  19. mutableSearch.addFilterValue('messaging.destination.name', destination, false);
  20. }
  21. return useSpanMetricsSeries(
  22. {
  23. yAxis,
  24. search: mutableSearch,
  25. enabled,
  26. },
  27. 'api.performance.queues.module-chart'
  28. );
  29. }