|
@@ -20,17 +20,21 @@ import {space} from 'sentry/styles/space';
|
|
import {RuleActionsCategories} from 'sentry/types/alerts';
|
|
import {RuleActionsCategories} from 'sentry/types/alerts';
|
|
import type {Organization} from 'sentry/types/organization';
|
|
import type {Organization} from 'sentry/types/organization';
|
|
import type {Project} from 'sentry/types/project';
|
|
import type {Project} from 'sentry/types/project';
|
|
|
|
+import {formatMRIField} from 'sentry/utils/metrics/mri';
|
|
import {shouldShowOnDemandMetricAlertUI} from 'sentry/utils/onDemandMetrics/features';
|
|
import {shouldShowOnDemandMetricAlertUI} from 'sentry/utils/onDemandMetrics/features';
|
|
import {ErrorMigrationWarning} from 'sentry/views/alerts/rules/metric/details/errorMigrationWarning';
|
|
import {ErrorMigrationWarning} from 'sentry/views/alerts/rules/metric/details/errorMigrationWarning';
|
|
import MetricHistory from 'sentry/views/alerts/rules/metric/details/metricHistory';
|
|
import MetricHistory from 'sentry/views/alerts/rules/metric/details/metricHistory';
|
|
import type {MetricRule} from 'sentry/views/alerts/rules/metric/types';
|
|
import type {MetricRule} from 'sentry/views/alerts/rules/metric/types';
|
|
import {Dataset, TimePeriod} from 'sentry/views/alerts/rules/metric/types';
|
|
import {Dataset, TimePeriod} from 'sentry/views/alerts/rules/metric/types';
|
|
import {extractEventTypeFilterFromRule} from 'sentry/views/alerts/rules/metric/utils/getEventTypeFilter';
|
|
import {extractEventTypeFilterFromRule} from 'sentry/views/alerts/rules/metric/utils/getEventTypeFilter';
|
|
|
|
+import {getFormattedSpanMetricField} from 'sentry/views/alerts/rules/metric/utils/getFormattedSpanMetric';
|
|
|
|
+import {isSpanMetricAlert} from 'sentry/views/alerts/rules/metric/utils/isSpanMetricAlert';
|
|
import {isOnDemandMetricAlert} from 'sentry/views/alerts/rules/metric/utils/onDemandMetricAlert';
|
|
import {isOnDemandMetricAlert} from 'sentry/views/alerts/rules/metric/utils/onDemandMetricAlert';
|
|
import {getAlertRuleActionCategory} from 'sentry/views/alerts/rules/utils';
|
|
import {getAlertRuleActionCategory} from 'sentry/views/alerts/rules/utils';
|
|
import type {Incident} from 'sentry/views/alerts/types';
|
|
import type {Incident} from 'sentry/views/alerts/types';
|
|
import {AlertRuleStatus} from 'sentry/views/alerts/types';
|
|
import {AlertRuleStatus} from 'sentry/views/alerts/types';
|
|
import {alertDetailsLink} from 'sentry/views/alerts/utils';
|
|
import {alertDetailsLink} from 'sentry/views/alerts/utils';
|
|
|
|
+import {useMetricsExtractionRules} from 'sentry/views/settings/projectMetrics/utils/useMetricsExtractionRules';
|
|
|
|
|
|
import {isCrashFreeAlert} from '../utils/isCrashFreeAlert';
|
|
import {isCrashFreeAlert} from '../utils/isCrashFreeAlert';
|
|
import {isCustomMetricAlert} from '../utils/isCustomMetricAlert';
|
|
import {isCustomMetricAlert} from '../utils/isCustomMetricAlert';
|
|
@@ -68,6 +72,14 @@ export default function MetricDetailsBody({
|
|
location,
|
|
location,
|
|
router,
|
|
router,
|
|
}: MetricDetailsBodyProps) {
|
|
}: MetricDetailsBodyProps) {
|
|
|
|
+ const {data: metricExtractionRules} = useMetricsExtractionRules(
|
|
|
|
+ {
|
|
|
|
+ orgId: organization.slug,
|
|
|
|
+ projectId: project?.slug,
|
|
|
|
+ },
|
|
|
|
+ {enabled: isSpanMetricAlert(rule?.aggregate)}
|
|
|
|
+ );
|
|
|
|
+
|
|
function getPeriodInterval() {
|
|
function getPeriodInterval() {
|
|
const startDate = moment.utc(timePeriod.start);
|
|
const startDate = moment.utc(timePeriod.start);
|
|
const endDate = moment.utc(timePeriod.end);
|
|
const endDate = moment.utc(timePeriod.end);
|
|
@@ -158,6 +170,14 @@ export default function MetricDetailsBody({
|
|
isOnDemandMetricAlert(dataset, aggregate, query) &&
|
|
isOnDemandMetricAlert(dataset, aggregate, query) &&
|
|
shouldShowOnDemandMetricAlertUI(organization);
|
|
shouldShowOnDemandMetricAlertUI(organization);
|
|
|
|
|
|
|
|
+ let formattedAggregate = aggregate;
|
|
|
|
+ if (isCustomMetricAlert(aggregate)) {
|
|
|
|
+ formattedAggregate = formatMRIField(aggregate);
|
|
|
|
+ }
|
|
|
|
+ if (isSpanMetricAlert(aggregate)) {
|
|
|
|
+ formattedAggregate = getFormattedSpanMetricField(aggregate, metricExtractionRules);
|
|
|
|
+ }
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<Fragment>
|
|
<Fragment>
|
|
{selectedIncident?.alertRule.status === AlertRuleStatus.SNAPSHOT && (
|
|
{selectedIncident?.alertRule.status === AlertRuleStatus.SNAPSHOT && (
|
|
@@ -222,6 +242,7 @@ export default function MetricDetailsBody({
|
|
incidents={incidents}
|
|
incidents={incidents}
|
|
timePeriod={timePeriod}
|
|
timePeriod={timePeriod}
|
|
selectedIncident={selectedIncident}
|
|
selectedIncident={selectedIncident}
|
|
|
|
+ formattedAggregate={formattedAggregate}
|
|
organization={organization}
|
|
organization={organization}
|
|
project={project}
|
|
project={project}
|
|
interval={getPeriodInterval()}
|
|
interval={getPeriodInterval()}
|