Tempo: Added status to hard-coded fields (#77393)

* Added status to hard-coded fields

* Revert change
This commit is contained in:
Andre Pereira 2023-10-30 19:37:03 +00:00 committed by GitHub
parent 1ba30b4de3
commit 48b830fc50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@ import { createErrorNotification } from '../../../../core/copy/appNotification';
import { notifyApp } from '../../../../core/reducers/appNotification';
import { dispatch } from '../../../../store/store';
import { RawQuery } from '../../prometheus/querybuilder/shared/RawQuery';
import { TraceqlFilter } from '../dataquery.gen';
import { TraceqlFilter, TraceqlSearchScope } from '../dataquery.gen';
import { TempoDatasource } from '../datasource';
import { TempoQueryBuilderOptions } from '../traceql/TempoQueryBuilderOptions';
import { traceqlGrammar } from '../traceql/traceql';
@ -30,6 +30,8 @@ interface Props {
onBlur?: () => void;
}
const hardCodedFilterIds = ['min-duration', 'max-duration', 'status'];
const TraceQLSearch = ({ datasource, query, onChange }: Props) => {
const styles = useStyles2(getStyles);
const [error, setError] = useState<Error | FetchError | null>(null);
@ -95,9 +97,10 @@ const TraceQLSearch = ({ datasource, query, onChange }: Props) => {
staticTags.push('duration');
// Dynamic filters are all filters that don't match the ID of a filter in the datasource configuration
// The duration tag is a special case since its selector is hard-coded
// The duration and status fields are a special case since its selector is hard-coded
const dynamicFilters = (query.filters || []).filter(
(f) => f.tag !== 'duration' && (datasource.search?.filters?.findIndex((sf) => sf.id === f.id) || 0) === -1
(f) =>
!hardCodedFilterIds.includes(f.id) && (datasource.search?.filters?.findIndex((sf) => sf.id === f.id) || 0) === -1
);
return (
@ -127,6 +130,25 @@ const TraceQLSearch = ({ datasource, query, onChange }: Props) => {
</InlineSearchField>
)
)}
<InlineSearchField label={'Status'}>
<SearchField
filter={
findFilter('status') || {
id: 'status',
tag: 'status',
scope: TraceqlSearchScope.Intrinsic,
operator: '=',
}
}
datasource={datasource}
setError={setError}
updateFilter={updateFilter}
tags={[]}
hideScope={true}
hideTag={true}
query={traceQlQuery}
/>
</InlineSearchField>
<InlineSearchField
label={'Duration'}
tooltip="The span duration, i.e. end - start time of the span. Accepted units are ns, ms, s, m, h"