useQueuesTimeSeriesQuery.tsx 1.1 KB

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