Skip to content

feat(alerts): Load best effort data for spans dataset #88912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
5 changes: 5 additions & 0 deletions static/app/components/charts/eventsRequest.tsx
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ import type {AggregationOutputType} from 'sentry/utils/discover/fields';
import {getAggregateAlias, stripEquationPrefix} from 'sentry/utils/discover/fields';
import type {DiscoverDatasets} from 'sentry/utils/discover/types';
import type {QueryBatching} from 'sentry/utils/performance/contexts/genericQueryBatcher';
import type {SamplingMode} from 'sentry/views/explore/hooks/useProgressiveQuery';

export type TimeSeriesData = {
allTimeseriesData?: EventsStatsData;
@@ -199,6 +200,10 @@ type EventsRequestPartialProps = {
* Sample rate used for data extrapolation in OnDemandMetricsRequest
*/
sampleRate?: number;
/**
* The type of sampling mode used for EAP dataset requests
*/
sampling?: SamplingMode;
/**
* Should loading be shown.
*/
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import {
AlertRuleThresholdType,
Dataset,
} from 'sentry/views/alerts/rules/metric/types';
import {SAMPLING_MODE} from 'sentry/views/explore/hooks/useProgressiveQuery';

const theme = ThemeFixture();

@@ -253,4 +254,53 @@ describe('Incident Rules Create', () => {
})
);
});

it('uses best effort sampling for span alerts', async () => {
const {organization, project, router} = initializeOrg({
organization: {features: ['visibility-explore-progressive-loading']},
});

render(
<TriggersChart
theme={theme}
api={api}
location={router.location}
organization={organization}
projects={[project]}
query=""
timeWindow={1}
aggregate="count(span.duration)"
dataset={Dataset.EVENTS_ANALYTICS_PLATFORM}
triggers={[]}
environment={null}
comparisonType={AlertRuleComparisonType.COUNT}
resolveThreshold={null}
thresholdType={AlertRuleThresholdType.BELOW}
newAlertOrQuery
onDataLoaded={() => {}}
isQueryValid
showTotalCount
/>
);

expect(await screen.findByTestId('area-chart')).toBeInTheDocument();
expect(await screen.findByTestId('alert-total-events')).toBeInTheDocument();

expect(eventStatsMock).toHaveBeenCalledWith(
expect.anything(),
expect.objectContaining({
query: {
interval: '1m',
project: [2],
query: '',
statsPeriod: '14d',
yAxis: 'count(span.duration)',
referrer: 'api.organization-event-stats',
dataset: 'spans',
sampling: SAMPLING_MODE.BEST_EFFORT,
useRpc: '1',
},
})
);
});
});
16 changes: 15 additions & 1 deletion static/app/views/alerts/rules/metric/triggers/chart/index.tsx
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ import {getComparisonMarkLines} from 'sentry/views/alerts/utils/getComparisonMar
import {AlertWizardAlertNames} from 'sentry/views/alerts/wizard/options';
import {getAlertTypeFromAggregateDataset} from 'sentry/views/alerts/wizard/utils';
import {ConfidenceFooter} from 'sentry/views/explore/charts/confidenceFooter';
import {SAMPLING_MODE} from 'sentry/views/explore/hooks/useProgressiveQuery';

import type {MetricRule, Trigger} from '../../types';
import {
@@ -747,7 +748,20 @@ class TriggersChart extends PureComponent<Props, State> {
{noop}
</EventsRequest>
) : null}
<EventsRequest {...baseProps} period={period} dataLoadedCallback={onDataLoaded}>
<EventsRequest
{...baseProps}
period={period}
dataLoadedCallback={onDataLoaded}
// Span alerts only need to do a best effort request and do not need
// preflight requests. A user needs to see the highest fidelity data possible
// to set up the alert.
sampling={
organization.features.includes('visibility-explore-progressive-loading') &&
dataset === Dataset.EVENTS_ANALYTICS_PLATFORM
? SAMPLING_MODE.BEST_EFFORT
: undefined
}
>
{({
loading,
errored,