Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function useMetricDetectorChart({
dataset: snubaQuery.dataset,
extrapolationMode: snubaQuery.extrapolationMode,
aggregate: datasetConfig.fromApiAggregate(snubaQuery.aggregate),
interval: snubaQuery.timeWindow,
timeWindow: snubaQuery.timeWindow,
query: snubaQuery.query,
environment: snubaQuery.environment,
projectId: detector.projectId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import ErrorBoundary from 'sentry/components/errorBoundary';
import {DatePageFilter} from 'sentry/components/organizations/datePageFilter';
import PageFilterBar from 'sentry/components/organizations/pageFilterBar';
import DetailLayout from 'sentry/components/workflowEngine/layout/detail';
import type {Project} from 'sentry/types/project';
import type {MetricDetector} from 'sentry/types/workflowEngine/detectors';
Expand All @@ -8,7 +10,6 @@ import {DetectorDetailsHeader} from 'sentry/views/detectors/components/details/c
import {DetectorDetailsOpenPeriodIssues} from 'sentry/views/detectors/components/details/common/openPeriodIssues';
import {MetricDetectorDetailsChart} from 'sentry/views/detectors/components/details/metric/chart';
import {MetricDetectorDetailsSidebar} from 'sentry/views/detectors/components/details/metric/sidebar';
import {MetricTimePeriodSelect} from 'sentry/views/detectors/components/details/metric/timePeriodSelect';
import {TransactionsDatasetWarning} from 'sentry/views/detectors/components/details/metric/transactionsDatasetWarning';
import {getDetectorDataset} from 'sentry/views/detectors/datasetConfig/getDetectorDataset';
import {DetectorDataset} from 'sentry/views/detectors/datasetConfig/types';
Expand All @@ -24,7 +25,6 @@ export function MetricDetectorDetails({detector, project}: MetricDetectorDetails

const snubaDataset = snubaQuery?.dataset ?? Dataset.ERRORS;
const eventTypes = snubaQuery?.eventTypes ?? [];
const interval = snubaQuery?.timeWindow;
const detectorDataset = getDetectorDataset(snubaDataset, eventTypes);

const intervalSeconds = dataSource.queryObj?.snubaQuery.timeWindow;
Expand All @@ -37,7 +37,9 @@ export function MetricDetectorDetails({detector, project}: MetricDetectorDetails
{detectorDataset === DetectorDataset.TRANSACTIONS && (
<TransactionsDatasetWarning />
)}
<MetricTimePeriodSelect dataset={detectorDataset} interval={interval} />
<PageFilterBar condensed>
<DatePageFilter />
</PageFilterBar>
{snubaQuery && (
<MetricDetectorDetailsChart detector={detector} snubaQuery={snubaQuery} />
)}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function MetricDetectorChart({
detectorDataset,
dataset,
aggregate,
interval,
timeWindow: interval,
query,
environment,
projectId,
Expand Down
8 changes: 4 additions & 4 deletions static/app/views/detectors/datasetConfig/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ interface DetectorSeriesQueryOptions {
dataset: Dataset;
environment: string;
eventTypes: EventTypes[];
/**
* Metric detector interval in seconds
*/
interval: number;
organization: Organization;
projectId: string;
/**
* The filter query. eg: `span.op:http`
*/
query: string;
/**
* Metric detector time window in seconds
*/
timeWindow: number;
end?: string | null;
/**
* Extra query parameters to pass
Expand Down
23 changes: 0 additions & 23 deletions static/app/views/detectors/datasetConfig/errors.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {OrganizationFixture} from 'sentry-fixture/organization';

import type {SnubaQuery} from 'sentry/types/workflowEngine/detectors';
import {Dataset, EventTypes} from 'sentry/views/alerts/rules/metric/types';
import {DetectorErrorsConfig} from 'sentry/views/detectors/datasetConfig/errors';
Expand Down Expand Up @@ -35,24 +33,3 @@ describe('DetectorErrorsConfig.toSnubaQueryString', () => {
expect(result).toBe('event.type:error is:unresolved');
});
});

describe('DetectorErrorsConfig.getSeriesQueryOptions', () => {
it('adjusts statsPeriod from 7d to 9998m when interval is 60 seconds', () => {
const options = {
aggregate: 'count()',
organization: OrganizationFixture(),
projectId: '1',
query: 'is:unresolved',
environment: '',
comparisonDelta: undefined,
dataset: Dataset.ERRORS,
eventTypes: [EventTypes.ERROR],
interval: 60,
statsPeriod: '7d',
};

const result = DetectorErrorsConfig.getSeriesQueryOptions(options);

expect(result[1]!.query!.statsPeriod).toBe('9998m');
});
});
15 changes: 9 additions & 6 deletions static/app/views/detectors/datasetConfig/errors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {DiscoverDatasets} from 'sentry/utils/discover/types';
import {AggregationKey, FieldKey} from 'sentry/utils/fields';
import {EventTypes} from 'sentry/views/alerts/rules/metric/types';
import {EventsSearchBar} from 'sentry/views/detectors/datasetConfig/components/eventSearchBar';
import {getChartInterval} from 'sentry/views/detectors/datasetConfig/utils/chartInterval';
import {
getDiscoverSeriesQueryOptions,
transformEventsStatsComparisonSeries,
Expand Down Expand Up @@ -81,16 +82,18 @@ export const DetectorErrorsConfig: DetectorDatasetConfig<ErrorsSeriesResponse> =
defaultField: DEFAULT_FIELD,
getAggregateOptions: () => AGGREGATE_OPTIONS,
getSeriesQueryOptions: options => {
// If interval is 1 minute and statsPeriod is 7 days, apply a 9998m statsPeriod to avoid the 10k results limit.
// Applied specifically to errors dataset because it has 1m intervals, spans/logs have a minimum of 5m intervals.
if (options.interval === 60 && options.statsPeriod === '7d') {
options.statsPeriod = '9998m';
}

return getDiscoverSeriesQueryOptions({
...options,
dataset: DetectorErrorsConfig.getDiscoverDataset(),
aggregate: translateAggregateTag(options.aggregate),
interval: getChartInterval({
timeWindow: options.timeWindow,
timeRange: {
statsPeriod: options.statsPeriod,
start: options.start,
end: options.end,
},
}),
});
},
getIntervals: ({detectionType}) => {
Expand Down
Loading
Loading