errorsAndTransactions.tsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. import * as Sentry from '@sentry/react';
  2. import trimStart from 'lodash/trimStart';
  3. import {doEventsRequest} from 'sentry/actionCreators/events';
  4. import type {Client, ResponseMeta} from 'sentry/api';
  5. import {isMultiSeriesStats} from 'sentry/components/charts/utils';
  6. import Link from 'sentry/components/links/link';
  7. import {Tooltip} from 'sentry/components/tooltip';
  8. import {t} from 'sentry/locale';
  9. import type {
  10. EventsStats,
  11. MultiSeriesEventsStats,
  12. Organization,
  13. PageFilters,
  14. SelectValue,
  15. TagCollection,
  16. } from 'sentry/types';
  17. import type {Series} from 'sentry/types/echarts';
  18. import {defined} from 'sentry/utils';
  19. import type {CustomMeasurementCollection} from 'sentry/utils/customMeasurements/customMeasurements';
  20. import type {EventsTableData, TableData} from 'sentry/utils/discover/discoverQuery';
  21. import type {MetaType} from 'sentry/utils/discover/eventView';
  22. import type {RenderFunctionBaggage} from 'sentry/utils/discover/fieldRenderers';
  23. import {getFieldRenderer} from 'sentry/utils/discover/fieldRenderers';
  24. import type {AggregationOutputType, QueryFieldValue} from 'sentry/utils/discover/fields';
  25. import {
  26. errorsAndTransactionsAggregateFunctionOutputType,
  27. getAggregateAlias,
  28. isEquation,
  29. isEquationAlias,
  30. isLegalYAxisType,
  31. SPAN_OP_BREAKDOWN_FIELDS,
  32. stripEquationPrefix,
  33. } from 'sentry/utils/discover/fields';
  34. import type {
  35. DiscoverQueryExtras,
  36. DiscoverQueryRequestParams,
  37. } from 'sentry/utils/discover/genericDiscoverQuery';
  38. import {doDiscoverQuery} from 'sentry/utils/discover/genericDiscoverQuery';
  39. import {Container} from 'sentry/utils/discover/styles';
  40. import {TOP_N} from 'sentry/utils/discover/types';
  41. import {
  42. eventDetailsRouteWithEventView,
  43. generateEventSlug,
  44. } from 'sentry/utils/discover/urls';
  45. import {getShortEventId} from 'sentry/utils/events';
  46. import {FieldKey} from 'sentry/utils/fields';
  47. import {getMeasurements} from 'sentry/utils/measurements/measurements';
  48. import {MEPState} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  49. import type {OnDemandControlContext} from 'sentry/utils/performance/contexts/onDemandControl';
  50. import {shouldUseOnDemandMetrics} from 'sentry/utils/performance/contexts/onDemandControl';
  51. import type {FieldValueOption} from 'sentry/views/discover/table/queryField';
  52. import type {FieldValue} from 'sentry/views/discover/table/types';
  53. import {FieldValueKind} from 'sentry/views/discover/table/types';
  54. import {generateFieldOptions} from 'sentry/views/discover/utils';
  55. import {getTraceDetailsUrl} from 'sentry/views/performance/traceDetails/utils';
  56. import {
  57. createUnnamedTransactionsDiscoverTarget,
  58. DiscoverQueryPageSource,
  59. UNPARAMETERIZED_TRANSACTION,
  60. } from 'sentry/views/performance/utils';
  61. import type {Widget, WidgetQuery} from '../types';
  62. import {DisplayType} from '../types';
  63. import {
  64. eventViewFromWidget,
  65. getDashboardsMEPQueryParams,
  66. getNumEquations,
  67. getWidgetInterval,
  68. } from '../utils';
  69. import {EventsSearchBar} from '../widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar';
  70. import {CUSTOM_EQUATION_VALUE} from '../widgetBuilder/buildSteps/sortByStep';
  71. import {
  72. flattenMultiSeriesDataWithGrouping,
  73. transformSeries,
  74. } from '../widgetCard/widgetQueries';
  75. import type {DatasetConfig} from './base';
  76. import {handleOrderByReset} from './base';
  77. const DEFAULT_WIDGET_QUERY: WidgetQuery = {
  78. name: '',
  79. fields: ['count()'],
  80. columns: [],
  81. fieldAliases: [],
  82. aggregates: ['count()'],
  83. conditions: '',
  84. orderby: '-count()',
  85. };
  86. export type SeriesWithOrdering = [order: number, series: Series];
  87. export const ErrorsAndTransactionsConfig: DatasetConfig<
  88. EventsStats | MultiSeriesEventsStats,
  89. TableData | EventsTableData
  90. > = {
  91. defaultWidgetQuery: DEFAULT_WIDGET_QUERY,
  92. enableEquations: true,
  93. getCustomFieldRenderer: getCustomEventsFieldRenderer,
  94. SearchBar: EventsSearchBar,
  95. filterSeriesSortOptions,
  96. filterYAxisAggregateParams,
  97. filterYAxisOptions,
  98. getTableFieldOptions: getEventsTableFieldOptions,
  99. getTimeseriesSortOptions,
  100. getTableSortOptions,
  101. getGroupByFieldOptions: getEventsTableFieldOptions,
  102. handleOrderByReset,
  103. supportedDisplayTypes: [
  104. DisplayType.AREA,
  105. DisplayType.BAR,
  106. DisplayType.BIG_NUMBER,
  107. DisplayType.LINE,
  108. DisplayType.TABLE,
  109. DisplayType.TOP_N,
  110. ],
  111. getTableRequest: (
  112. api: Client,
  113. widget: Widget,
  114. query: WidgetQuery,
  115. organization: Organization,
  116. pageFilters: PageFilters,
  117. onDemandControlContext?: OnDemandControlContext,
  118. limit?: number,
  119. cursor?: string,
  120. referrer?: string,
  121. mepSetting?: MEPState | null
  122. ) => {
  123. const url = `/organizations/${organization.slug}/events/`;
  124. const queryExtras = {
  125. useOnDemandMetrics: shouldUseOnDemandMetrics(
  126. organization,
  127. widget,
  128. onDemandControlContext
  129. ),
  130. onDemandType: 'dynamic_query',
  131. };
  132. return getEventsRequest(
  133. url,
  134. api,
  135. query,
  136. organization,
  137. pageFilters,
  138. limit,
  139. cursor,
  140. referrer,
  141. mepSetting,
  142. queryExtras
  143. );
  144. },
  145. getSeriesRequest: getEventsSeriesRequest,
  146. transformSeries: transformEventsResponseToSeries,
  147. transformTable: transformEventsResponseToTable,
  148. filterAggregateParams,
  149. getSeriesResultType,
  150. };
  151. function getTableSortOptions(_organization: Organization, widgetQuery: WidgetQuery) {
  152. const {columns, aggregates} = widgetQuery;
  153. const options: SelectValue<string>[] = [];
  154. let equations = 0;
  155. [...aggregates, ...columns]
  156. .filter(field => !!field)
  157. .forEach(field => {
  158. let alias;
  159. const label = stripEquationPrefix(field);
  160. // Equations are referenced via a standard alias following this pattern
  161. if (isEquation(field)) {
  162. alias = `equation[${equations}]`;
  163. equations += 1;
  164. }
  165. options.push({label, value: alias ?? field});
  166. });
  167. return options;
  168. }
  169. function filterSeriesSortOptions(columns: Set<string>) {
  170. return (option: FieldValueOption) => {
  171. if (
  172. option.value.kind === FieldValueKind.FUNCTION ||
  173. option.value.kind === FieldValueKind.EQUATION
  174. ) {
  175. return true;
  176. }
  177. return (
  178. columns.has(option.value.meta.name) ||
  179. option.value.meta.name === CUSTOM_EQUATION_VALUE
  180. );
  181. };
  182. }
  183. function getTimeseriesSortOptions(
  184. organization: Organization,
  185. widgetQuery: WidgetQuery,
  186. tags?: TagCollection
  187. ) {
  188. const options: Record<string, SelectValue<FieldValue>> = {};
  189. options[`field:${CUSTOM_EQUATION_VALUE}`] = {
  190. label: 'Custom Equation',
  191. value: {
  192. kind: FieldValueKind.EQUATION,
  193. meta: {name: CUSTOM_EQUATION_VALUE},
  194. },
  195. };
  196. let equations = 0;
  197. [...widgetQuery.aggregates, ...widgetQuery.columns]
  198. .filter(field => !!field)
  199. .forEach(field => {
  200. let alias;
  201. const label = stripEquationPrefix(field);
  202. // Equations are referenced via a standard alias following this pattern
  203. if (isEquation(field)) {
  204. alias = `equation[${equations}]`;
  205. equations += 1;
  206. options[`equation:${alias}`] = {
  207. label,
  208. value: {
  209. kind: FieldValueKind.EQUATION,
  210. meta: {
  211. name: alias ?? field,
  212. },
  213. },
  214. };
  215. }
  216. });
  217. const fieldOptions = getEventsTableFieldOptions(organization, tags);
  218. return {...options, ...fieldOptions};
  219. }
  220. function getEventsTableFieldOptions(
  221. organization: Organization,
  222. tags?: TagCollection,
  223. customMeasurements?: CustomMeasurementCollection
  224. ) {
  225. const measurements = getMeasurements();
  226. return generateFieldOptions({
  227. organization,
  228. tagKeys: Object.values(tags ?? {}).map(({key}) => key),
  229. measurementKeys: Object.values(measurements).map(({key}) => key),
  230. spanOperationBreakdownKeys: SPAN_OP_BREAKDOWN_FIELDS,
  231. customMeasurements: Object.values(customMeasurements ?? {}).map(
  232. ({key, functions}) => ({
  233. key,
  234. functions,
  235. })
  236. ),
  237. });
  238. }
  239. function transformEventsResponseToTable(
  240. data: TableData | EventsTableData,
  241. _widgetQuery: WidgetQuery
  242. ): TableData {
  243. let tableData = data;
  244. // events api uses a different response format so we need to construct tableData differently
  245. const {fields, ...otherMeta} = (data as EventsTableData).meta ?? {};
  246. tableData = {
  247. ...data,
  248. meta: {...fields, ...otherMeta},
  249. } as TableData;
  250. return tableData as TableData;
  251. }
  252. function filterYAxisAggregateParams(
  253. fieldValue: QueryFieldValue,
  254. displayType: DisplayType
  255. ) {
  256. return (option: FieldValueOption) => {
  257. // Only validate function parameters for timeseries widgets and
  258. // world map widgets.
  259. if (displayType === DisplayType.BIG_NUMBER) {
  260. return true;
  261. }
  262. if (fieldValue.kind !== FieldValueKind.FUNCTION) {
  263. return true;
  264. }
  265. const functionName = fieldValue.function[0];
  266. const primaryOutput = errorsAndTransactionsAggregateFunctionOutputType(
  267. functionName as string,
  268. option.value.meta.name
  269. );
  270. if (primaryOutput) {
  271. return isLegalYAxisType(primaryOutput);
  272. }
  273. if (
  274. option.value.kind === FieldValueKind.FUNCTION ||
  275. option.value.kind === FieldValueKind.EQUATION
  276. ) {
  277. // Functions and equations are not legal options as an aggregate/function parameter.
  278. return false;
  279. }
  280. return isLegalYAxisType(option.value.meta.dataType);
  281. };
  282. }
  283. function filterYAxisOptions(displayType: DisplayType) {
  284. return (option: FieldValueOption) => {
  285. // Only validate function names for timeseries widgets and
  286. // world map widgets.
  287. if (
  288. !(displayType === DisplayType.BIG_NUMBER) &&
  289. option.value.kind === FieldValueKind.FUNCTION
  290. ) {
  291. const primaryOutput = errorsAndTransactionsAggregateFunctionOutputType(
  292. option.value.meta.name,
  293. undefined
  294. );
  295. if (primaryOutput) {
  296. // If a function returns a specific type, then validate it.
  297. return isLegalYAxisType(primaryOutput);
  298. }
  299. }
  300. return option.value.kind === FieldValueKind.FUNCTION;
  301. };
  302. }
  303. function transformEventsResponseToSeries(
  304. data: EventsStats | MultiSeriesEventsStats,
  305. widgetQuery: WidgetQuery
  306. ): Series[] {
  307. let output: Series[] = [];
  308. const queryAlias = widgetQuery.name;
  309. if (isMultiSeriesStats(data)) {
  310. let seriesWithOrdering: SeriesWithOrdering[] = [];
  311. const isMultiSeriesDataWithGrouping =
  312. widgetQuery.aggregates.length > 1 && widgetQuery.columns.length;
  313. // Convert multi-series results into chartable series. Multi series results
  314. // are created when multiple yAxis are used. Convert the timeseries
  315. // data into a multi-series data set. As the server will have
  316. // replied with a map like: {[titleString: string]: EventsStats}
  317. if (isMultiSeriesDataWithGrouping) {
  318. seriesWithOrdering = flattenMultiSeriesDataWithGrouping(data, queryAlias);
  319. } else {
  320. seriesWithOrdering = Object.keys(data).map((seriesName: string) => {
  321. const prefixedName = queryAlias ? `${queryAlias} : ${seriesName}` : seriesName;
  322. const seriesData: EventsStats = data[seriesName];
  323. return [
  324. seriesData.order || 0,
  325. transformSeries(seriesData, prefixedName, seriesName),
  326. ];
  327. });
  328. }
  329. output = [
  330. ...seriesWithOrdering
  331. .sort((itemA, itemB) => itemA[0] - itemB[0])
  332. .map(item => item[1]),
  333. ];
  334. } else {
  335. const field = widgetQuery.aggregates[0];
  336. const prefixedName = queryAlias ? `${queryAlias} : ${field}` : field;
  337. const transformed = transformSeries(data, prefixedName, field);
  338. output.push(transformed);
  339. }
  340. return output;
  341. }
  342. // Get the series result type from the EventsStats meta
  343. function getSeriesResultType(
  344. data: EventsStats | MultiSeriesEventsStats,
  345. widgetQuery: WidgetQuery
  346. ): Record<string, AggregationOutputType> {
  347. const field = widgetQuery.aggregates[0];
  348. const resultTypes = {};
  349. // Need to use getAggregateAlias since events-stats still uses aggregate alias format
  350. if (isMultiSeriesStats(data)) {
  351. Object.keys(data).forEach(
  352. key => (resultTypes[key] = data[key].meta?.fields[getAggregateAlias(key)])
  353. );
  354. } else {
  355. resultTypes[field] = data.meta?.fields[getAggregateAlias(field)];
  356. }
  357. return resultTypes;
  358. }
  359. function renderEventIdAsLinkable(data, {eventView, organization}: RenderFunctionBaggage) {
  360. const id: string | unknown = data?.id;
  361. if (!eventView || typeof id !== 'string') {
  362. return null;
  363. }
  364. const eventSlug = generateEventSlug(data);
  365. const target = eventDetailsRouteWithEventView({
  366. orgSlug: organization.slug,
  367. eventSlug,
  368. eventView,
  369. });
  370. return (
  371. <Tooltip title={t('View Event')}>
  372. <Link data-test-id="view-event" to={target}>
  373. <Container>{getShortEventId(id)}</Container>
  374. </Link>
  375. </Tooltip>
  376. );
  377. }
  378. function renderTraceAsLinkable(
  379. data,
  380. {eventView, organization, location}: RenderFunctionBaggage
  381. ) {
  382. const id: string | unknown = data?.trace;
  383. if (!eventView || typeof id !== 'string') {
  384. return null;
  385. }
  386. const dateSelection = eventView.normalizeDateSelection(location);
  387. const target = getTraceDetailsUrl(organization, String(data.trace), dateSelection, {});
  388. return (
  389. <Tooltip title={t('View Trace')}>
  390. <Link data-test-id="view-trace" to={target}>
  391. <Container>{getShortEventId(id)}</Container>
  392. </Link>
  393. </Tooltip>
  394. );
  395. }
  396. export function getCustomEventsFieldRenderer(field: string, meta: MetaType) {
  397. if (field === 'id') {
  398. return renderEventIdAsLinkable;
  399. }
  400. if (field === 'trace') {
  401. return renderTraceAsLinkable;
  402. }
  403. // When title or transaction are << unparameterized >>, link out to discover showing unparameterized transactions
  404. if (['title', 'transaction'].includes(field)) {
  405. return function (data, baggage) {
  406. if (data[field] === UNPARAMETERIZED_TRANSACTION) {
  407. return (
  408. <Container>
  409. <Link
  410. to={createUnnamedTransactionsDiscoverTarget({
  411. location: baggage.location,
  412. organization: baggage.organization,
  413. source: DiscoverQueryPageSource.DISCOVER,
  414. })}
  415. >
  416. {data[field]}
  417. </Link>
  418. </Container>
  419. );
  420. }
  421. return getFieldRenderer(field, meta, false)(data, baggage);
  422. };
  423. }
  424. return getFieldRenderer(field, meta, false);
  425. }
  426. function getEventsRequest(
  427. url: string,
  428. api: Client,
  429. query: WidgetQuery,
  430. _organization: Organization,
  431. pageFilters: PageFilters,
  432. limit?: number,
  433. cursor?: string,
  434. referrer?: string,
  435. mepSetting?: MEPState | null,
  436. queryExtras?: DiscoverQueryExtras
  437. ) {
  438. const isMEPEnabled = defined(mepSetting) && mepSetting !== MEPState.TRANSACTIONS_ONLY;
  439. const eventView = eventViewFromWidget('', query, pageFilters);
  440. const params: DiscoverQueryRequestParams = {
  441. per_page: limit,
  442. cursor,
  443. referrer,
  444. ...getDashboardsMEPQueryParams(isMEPEnabled),
  445. ...queryExtras,
  446. };
  447. if (query.orderby) {
  448. params.sort = typeof query.orderby === 'string' ? [query.orderby] : query.orderby;
  449. }
  450. // TODO: eventually need to replace this with just EventsTableData as we deprecate eventsv2
  451. return doDiscoverQuery<TableData | EventsTableData>(
  452. api,
  453. url,
  454. {
  455. ...eventView.generateQueryStringObject(),
  456. ...params,
  457. },
  458. // Tries events request up to 3 times on rate limit
  459. {
  460. retry: {
  461. statusCodes: [429],
  462. tries: 3,
  463. },
  464. }
  465. );
  466. }
  467. function getEventsSeriesRequest(
  468. api: Client,
  469. widget: Widget,
  470. queryIndex: number,
  471. organization: Organization,
  472. pageFilters: PageFilters,
  473. onDemandControlContext?: OnDemandControlContext,
  474. referrer?: string,
  475. mepSetting?: MEPState | null
  476. ) {
  477. const widgetQuery = widget.queries[queryIndex];
  478. const {displayType, limit} = widget;
  479. const {environments, projects} = pageFilters;
  480. const {start, end, period: statsPeriod} = pageFilters.datetime;
  481. const interval = getWidgetInterval(displayType, {start, end, period: statsPeriod});
  482. const isMEPEnabled = defined(mepSetting) && mepSetting !== MEPState.TRANSACTIONS_ONLY;
  483. let requestData;
  484. if (displayType === DisplayType.TOP_N) {
  485. requestData = {
  486. organization,
  487. interval,
  488. start,
  489. end,
  490. project: projects,
  491. environment: environments,
  492. period: statsPeriod,
  493. query: widgetQuery.conditions,
  494. yAxis: widgetQuery.aggregates[widgetQuery.aggregates.length - 1],
  495. includePrevious: false,
  496. referrer,
  497. partial: true,
  498. field: [...widgetQuery.columns, ...widgetQuery.aggregates],
  499. queryExtras: getDashboardsMEPQueryParams(isMEPEnabled),
  500. includeAllArgs: true,
  501. topEvents: TOP_N,
  502. };
  503. if (widgetQuery.orderby) {
  504. requestData.orderby = widgetQuery.orderby;
  505. }
  506. } else {
  507. requestData = {
  508. organization,
  509. interval,
  510. start,
  511. end,
  512. project: projects,
  513. environment: environments,
  514. period: statsPeriod,
  515. query: widgetQuery.conditions,
  516. yAxis: widgetQuery.aggregates,
  517. orderby: widgetQuery.orderby,
  518. includePrevious: false,
  519. referrer,
  520. partial: true,
  521. queryExtras: getDashboardsMEPQueryParams(isMEPEnabled),
  522. includeAllArgs: true,
  523. };
  524. if (widgetQuery.columns?.length !== 0) {
  525. requestData.topEvents = limit ?? TOP_N;
  526. requestData.field = [...widgetQuery.columns, ...widgetQuery.aggregates];
  527. // Compare field and orderby as aliases to ensure requestData has
  528. // the orderby selected
  529. // If the orderby is an equation alias, do not inject it
  530. const orderby = trimStart(widgetQuery.orderby, '-');
  531. if (
  532. widgetQuery.orderby &&
  533. !isEquationAlias(orderby) &&
  534. !requestData.field.includes(orderby)
  535. ) {
  536. requestData.field.push(orderby);
  537. }
  538. // The "Other" series is only included when there is one
  539. // y-axis and one widgetQuery
  540. requestData.excludeOther =
  541. widgetQuery.aggregates.length !== 1 || widget.queries.length !== 1;
  542. if (isEquation(trimStart(widgetQuery.orderby, '-'))) {
  543. const nextEquationIndex = getNumEquations(widgetQuery.aggregates);
  544. const isDescending = widgetQuery.orderby.startsWith('-');
  545. const prefix = isDescending ? '-' : '';
  546. // Construct the alias form of the equation and inject it into the request
  547. requestData.orderby = `${prefix}equation[${nextEquationIndex}]`;
  548. requestData.field = [
  549. ...widgetQuery.columns,
  550. ...widgetQuery.aggregates,
  551. trimStart(widgetQuery.orderby, '-'),
  552. ];
  553. }
  554. }
  555. }
  556. if (shouldUseOnDemandMetrics(organization, widget, onDemandControlContext)) {
  557. return doOnDemandMetricsRequest(api, requestData);
  558. }
  559. return doEventsRequest<true>(api, requestData);
  560. }
  561. async function doOnDemandMetricsRequest(
  562. api,
  563. requestData
  564. ): Promise<
  565. [EventsStats | MultiSeriesEventsStats, string | undefined, ResponseMeta | undefined]
  566. > {
  567. try {
  568. const isEditing = location.pathname.endsWith('/edit/');
  569. const fetchEstimatedStats = () =>
  570. `/organizations/${requestData.organization.slug}/metrics-estimation-stats/`;
  571. const response = await doEventsRequest<false>(api, {
  572. ...requestData,
  573. queryExtras: {
  574. ...requestData.queryExtras,
  575. useOnDemandMetrics: true,
  576. onDemandType: 'dynamic_query',
  577. },
  578. dataset: 'metricsEnhanced',
  579. generatePathname: isEditing ? fetchEstimatedStats : undefined,
  580. });
  581. response[0] = {...response[0], isMetricsData: true, isExtrapolatedData: isEditing};
  582. return [response[0], response[1], response[2]];
  583. } catch (err) {
  584. Sentry.captureMessage('Failed to fetch metrics estimation stats', {extra: err});
  585. return doEventsRequest<true>(api, requestData);
  586. }
  587. }
  588. // Checks fieldValue to see what function is being used and only allow supported custom measurements
  589. function filterAggregateParams(option: FieldValueOption, fieldValue?: QueryFieldValue) {
  590. if (
  591. (option.value.kind === FieldValueKind.CUSTOM_MEASUREMENT &&
  592. fieldValue?.kind === 'function' &&
  593. fieldValue?.function &&
  594. !option.value.meta.functions.includes(fieldValue.function[0])) ||
  595. option.value.meta.name === FieldKey.TOTAL_COUNT
  596. ) {
  597. return false;
  598. }
  599. return true;
  600. }