diff --git a/static/app/actionCreators/events.tsx b/static/app/actionCreators/events.tsx index ee790bdd5db21..bfb40d59a7fde 100644 --- a/static/app/actionCreators/events.tsx +++ b/static/app/actionCreators/events.tsx @@ -54,6 +54,7 @@ type Options = { start?: DateString; team?: Readonly; topEvents?: number; + useOnDemandMetrics?: boolean; withoutZerofill?: boolean; yAxis?: string | string[]; }; @@ -105,6 +106,7 @@ export const doEventsRequest = ( excludeOther, includeAllArgs, dataset, + useOnDemandMetrics, }: {includeAllArgs?: IncludeAllArgsType} & Options ): IncludeAllArgsType extends true ? Promise< @@ -133,6 +135,7 @@ export const doEventsRequest = ( referrer: referrer ? referrer : 'api.organization-event-stats', excludeOther: excludeOther ? '1' : undefined, dataset, + useOnDemandMetrics, }).filter(([, value]) => typeof value !== 'undefined') ); diff --git a/static/app/components/charts/eventsRequest.tsx b/static/app/components/charts/eventsRequest.tsx index 66afeb60cfaa8..6843c65bb5989 100644 --- a/static/app/components/charts/eventsRequest.tsx +++ b/static/app/components/charts/eventsRequest.tsx @@ -209,6 +209,11 @@ type EventsRequestPartialProps = { * in the `results` child render function. */ topEvents?: number; + /** + * Whether or not to use on demand metrics + * This is a temporary flag to allow us to test on demand metrics + */ + useOnDemandMetrics?: boolean; /** * Whether or not to zerofill results */ diff --git a/static/app/views/alerts/rules/metric/create.spec.tsx b/static/app/views/alerts/rules/metric/create.spec.tsx index 067674f40f1a9..17ddb480d10b8 100644 --- a/static/app/views/alerts/rules/metric/create.spec.tsx +++ b/static/app/views/alerts/rules/metric/create.spec.tsx @@ -66,6 +66,7 @@ describe('Incident Rules Create', function () { statsPeriod: '10000m', yAxis: 'count()', referrer: 'api.organization-event-stats', + useOnDemandMetrics: false, }, }) ); diff --git a/static/app/views/alerts/rules/metric/details/body.tsx b/static/app/views/alerts/rules/metric/details/body.tsx index 451f00e53a086..dfec3f7d8a2cb 100644 --- a/static/app/views/alerts/rules/metric/details/body.tsx +++ b/static/app/views/alerts/rules/metric/details/body.tsx @@ -21,6 +21,7 @@ import {RuleActionsCategories} from 'sentry/types/alerts'; import MetricHistory from 'sentry/views/alerts/rules/metric/details/metricHistory'; import {Dataset, MetricRule, TimePeriod} from 'sentry/views/alerts/rules/metric/types'; import {extractEventTypeFilterFromRule} from 'sentry/views/alerts/rules/metric/utils/getEventTypeFilter'; +import {isOnDemandMetricAlert} from 'sentry/views/alerts/rules/metric/utils/onDemandMetricAlert'; import {getAlertRuleActionCategory} from 'sentry/views/alerts/rules/utils'; import {AlertRuleStatus, Incident} from '../../../types'; @@ -216,6 +217,7 @@ export default class DetailsBody extends Component { interval={this.getInterval()} query={isCrashFreeAlert(dataset) ? query : queryWithTypeFilter} filter={this.getFilter()} + isOnDemandMetricAlert={isOnDemandMetricAlert(dataset, query)} /> diff --git a/static/app/views/alerts/rules/metric/details/metricChart.tsx b/static/app/views/alerts/rules/metric/details/metricChart.tsx index 0c0227e96d517..fe1cfd5c4d782 100644 --- a/static/app/views/alerts/rules/metric/details/metricChart.tsx +++ b/static/app/views/alerts/rules/metric/details/metricChart.tsx @@ -55,7 +55,6 @@ import { MetricRule, TimePeriod, } from 'sentry/views/alerts/rules/metric/types'; -import {isOnDemandMetricAlert} from 'sentry/views/alerts/rules/metric/utils/onDemandMetricAlert'; import {getChangeStatus} from 'sentry/views/alerts/utils/getChangeStatus'; import {AlertWizardAlertNames} from 'sentry/views/alerts/wizard/options'; import {getAlertTypeFromAggregateDataset} from 'sentry/views/alerts/wizard/utils'; @@ -86,6 +85,7 @@ type Props = WithRouterProps & { rule: MetricRule; timePeriod: TimePeriodType; incidents?: Incident[]; + isOnDemandMetricAlert?: boolean; selectedIncident?: Incident | null; }; @@ -466,8 +466,17 @@ class MetricChart extends PureComponent { } render() { - const {api, rule, organization, timePeriod, project, interval, query, location} = - this.props; + const { + api, + rule, + organization, + timePeriod, + project, + interval, + query, + location, + isOnDemandMetricAlert, + } = this.props; const {aggregate, timeWindow, environment, dataset} = rule; // Fix for 7 days * 1m interval being over the max number of results from events api @@ -503,14 +512,6 @@ class MetricChart extends PureComponent { newAlertOrQuery: false, }); - if (isOnDemandMetricAlert(rule.dataset, rule.query)) { - return this.renderEmpty( - t( - 'This alert includes advanced conditions, which is a feature that is currently in early access. Charts are not yet supported at this time.' - ) - ); - } - return isCrashFreeAlert(dataset) ? ( { partial={false} queryExtras={queryExtras} referrer="api.alerts.alert-rule-chart" + useOnDemandMetrics={isOnDemandMetricAlert} > {({loading, timeseriesData, comparisonTimeseriesData}) => this.renderChart(loading, timeseriesData, undefined, comparisonTimeseriesData) diff --git a/static/app/views/alerts/rules/metric/triggers/chart/index.tsx b/static/app/views/alerts/rules/metric/triggers/chart/index.tsx index 1149ff263ab48..8266279f3ea4a 100644 --- a/static/app/views/alerts/rules/metric/triggers/chart/index.tsx +++ b/static/app/views/alerts/rules/metric/triggers/chart/index.tsx @@ -448,6 +448,7 @@ class TriggersChart extends PureComponent { partial={false} queryExtras={queryExtras} dataLoadedCallback={handleMEPAlertDataset} + useOnDemandMetrics={isOnDemandMetricAlert} > {({ loading,