Skip to content

Commit

Permalink
fix(metrics-extraction): Include extraction state in on-demand check (#…
Browse files Browse the repository at this point in the history
…76549)

### Summary
This adds a check for any on-demand state being 'disabled' (eg. spec
limit, cardinality limit) for a widget, and stops it from querying
on-demand metrics on the backend.

#### Other
- This can also be handled by the backend, but since that requires
determining the widget id in question it leaks dashboard domain into our
events/event-stats endpoints.
- Closes #76050
  • Loading branch information
k-fish committed Aug 27, 2024
1 parent 2ff06d3 commit 9bc349c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions static/app/utils/performance/contexts/onDemandControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export function isOnDemandMetricWidget(widget: Widget): boolean {
const doesWidgetHaveReleaseConditions = (widget: Widget) =>
widget.queries.some(q => q.conditions.includes('release:'));

/**
* Check the extraction state for any widgets exceeding spec limit / cardinality limit etc.
*/
const doesWidgetHaveDisabledOnDemand = (widget: Widget) =>
widget.queries.some(q => q.onDemand?.some(d => !d.enabled));

export const shouldUseOnDemandMetrics = (
organization: Organization,
widget: Widget,
Expand All @@ -121,6 +127,10 @@ export const shouldUseOnDemandMetrics = (
return false;
}

if (doesWidgetHaveDisabledOnDemand(widget)) {
return false;
}

return isOnDemandMetricWidget(widget);
};

Expand Down

0 comments on commit 9bc349c

Please sign in to comment.