useQueuesMetricsQuery.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  2. import {DEFAULT_QUERY_FILTER} from 'sentry/views/performance/queues/settings';
  3. import {useSpanMetrics} from 'sentry/views/starfish/queries/useSpanMetrics';
  4. type Props = {
  5. destination?: string;
  6. enabled?: boolean;
  7. transaction?: string;
  8. };
  9. export function useQueuesMetricsQuery({destination, transaction, enabled}: Props) {
  10. const mutableSearch = new MutableSearch(DEFAULT_QUERY_FILTER);
  11. if (destination) {
  12. // TODO: This should filter by destination, not transaction
  13. mutableSearch.addFilterValue('transaction', destination);
  14. }
  15. if (transaction) {
  16. mutableSearch.addFilterValue('transaction', transaction);
  17. }
  18. const response = useSpanMetrics({
  19. search: mutableSearch,
  20. fields: [
  21. 'count()',
  22. 'count_op(queue.submit.celery)',
  23. 'count_op(queue.task.celery)',
  24. 'sum(span.self_time)',
  25. 'avg(span.self_time)',
  26. 'avg_if(span.self_time,span.op,queue.submit.celery)',
  27. 'avg_if(span.self_time,span.op,queue.task.celery)',
  28. ],
  29. enabled,
  30. sorts: [],
  31. limit: 10,
  32. referrer: 'api.performance.queues.destination-summary',
  33. });
  34. return response;
  35. }