Skip to content
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

feat(alerts): Update EAP Alert builder to use EAPSpanSearchQueryBuilder and Span Tags Provider #81152

Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -30,6 +30,7 @@ interface SpanSearchQueryBuilderProps {
searchSource: string;
datetime?: PageFilters['datetime'];
disableLoadingTags?: boolean;
onBlur?: (query: string, state: CallbackSearchState) => void;
onSearch?: (query: string, state: CallbackSearchState) => void;
placeholder?: string;
projects?: PageFilters['projects'];
Expand Down Expand Up @@ -59,6 +60,7 @@ export function SpanSearchQueryBuilder({
searchSource,
datetime,
onSearch,
onBlur,
placeholder,
projects,
}: SpanSearchQueryBuilderProps) {
Expand Down Expand Up @@ -135,6 +137,7 @@ export function SpanSearchQueryBuilder({
initialQuery={initialQuery}
fieldDefinitionGetter={getSpanFieldDefinition}
onSearch={onSearch}
onBlur={onBlur}
searchSource={searchSource}
filterKeySections={filterKeySections}
getTagValues={getSpanFilterTagValues}
Expand All @@ -155,6 +158,7 @@ export function EAPSpanSearchQueryBuilder({
initialQuery,
placeholder,
onSearch,
onBlur,
searchSource,
numberTags,
stringTags,
Expand Down Expand Up @@ -226,6 +230,7 @@ export function EAPSpanSearchQueryBuilder({
initialQuery={initialQuery}
fieldDefinitionGetter={getSpanFieldDefinition}
onSearch={onSearch}
onBlur={onBlur}
searchSource={searchSource}
filterKeySections={filterKeySections}
getTagValues={getSpanFilterTagValues}
Expand Down
36 changes: 35 additions & 1 deletion static/app/views/alerts/rules/metric/ruleConditionsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {MetricSearchBar} from 'sentry/components/metrics/metricSearchBar';
import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse';
import Panel from 'sentry/components/panels/panel';
import PanelBody from 'sentry/components/panels/panelBody';
import {EAPSpanSearchQueryBuilder} from 'sentry/components/performance/spanSearchQueryBuilder';
import {SearchQueryBuilder} from 'sentry/components/searchQueryBuilder';
import {InvalidReason} from 'sentry/components/searchSyntax/parser';
import {t, tct} from 'sentry/locale';
Expand All @@ -42,8 +43,14 @@ import type {Organization} from 'sentry/types/organization';
import type {Environment, Project} from 'sentry/types/project';
import {defined} from 'sentry/utils';
import {isAggregateField, isMeasurement} from 'sentry/utils/discover/fields';
import {DiscoverDatasets} from 'sentry/utils/discover/types';
import {getDisplayName} from 'sentry/utils/environment';
import {DEVICE_CLASS_TAG_VALUES, FieldKind, isDeviceClass} from 'sentry/utils/fields';
import {
ALLOWED_EXPLORE_VISUALIZE_AGGREGATES,
DEVICE_CLASS_TAG_VALUES,
FieldKind,
isDeviceClass,
} from 'sentry/utils/fields';
import {
getMeasurements,
type MeasurementCollection,
Expand All @@ -63,6 +70,10 @@ import {
} from 'sentry/views/alerts/utils';
import type {AlertType} from 'sentry/views/alerts/wizard/options';
import {getSupportedAndOmittedTags} from 'sentry/views/alerts/wizard/options';
import {
SpanTagsContext,
SpanTagsProvider,
} from 'sentry/views/explore/contexts/spanTagsContext';

import {getProjectOptions} from '../utils';

Expand Down Expand Up @@ -732,6 +743,29 @@ class RuleConditionsForm extends PureComponent<Props, State> {
onChange(query, {});
}}
/>
) : alertType === 'eap_metrics' ? (
<SpanTagsProvider dataset={DiscoverDatasets.SPANS_EAP}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to list this Provider higher at some point so you can use it to populate other parts of the form.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I think I'll save this for a follow up PR. Just want to keep these providers and context more localized for now until Explore is closer to EA and avoid running these providers higher up conditionally.

<SpanTagsContext.Consumer>
{tags => (
<EAPSpanSearchQueryBuilder
numberTags={tags?.number ?? {}}
stringTags={tags?.string ?? {}}
initialQuery={initialData?.query ?? ''}
searchSource="alerts"
onSearch={(query, {parsedQuery}) => {
onFilterSearch(query, parsedQuery);
onChange(query, {});
}}
onBlur={(query, {parsedQuery}) => {
onFilterSearch(query, parsedQuery);
onBlur(query);
}}
supportedAggregates={ALLOWED_EXPLORE_VISUALIZE_AGGREGATES}
projects={[parseInt(project.id, 10)]}
/>
)}
</SpanTagsContext.Consumer>
</SpanTagsProvider>
) : (
<SearchContainer>
<SearchQueryBuilder
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/explore/contexts/spanTagsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TypedSpanTags = {
string: TagCollection;
};

const SpanTagsContext = createContext<TypedSpanTags | undefined>(undefined);
export const SpanTagsContext = createContext<TypedSpanTags | undefined>(undefined);

interface SpanTagsProviderProps {
children: React.ReactNode;
Expand Down
Loading