Manually set query type in Tempo explore on component mount (#38408)

* Manually set query type in Tempo explore on component mount
This commit is contained in:
Connor Lindsey 2021-08-23 07:51:45 -06:00 committed by GitHub
parent 74fef637af
commit a2525005e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,6 +62,14 @@ class TempoQueryFieldComponent extends React.PureComponent<Props, State> {
serviceMapDatasourceUid: serviceMapDsUid,
serviceMapDatasource: serviceMapDs as PrometheusDatasource,
});
// Set initial query type to ensure traceID field appears
if (!this.props.query.queryType) {
this.props.onChange({
...this.props.query,
queryType: DEFAULT_QUERY_TYPE,
});
}
}
onChangeLinkedQuery = (value: LokiQuery) => {
@ -97,7 +105,13 @@ class TempoQueryFieldComponent extends React.PureComponent<Props, State> {
}
if (logsDatasourceUid) {
queryTypeOptions.push({ value: 'search', label: 'Loki Search' });
if (!config.featureToggles.tempoSearch) {
// Place at beginning as Search if no native search
queryTypeOptions.unshift({ value: 'search', label: 'Search' });
} else {
// Place at end as Loki Search if native search is enabled
queryTypeOptions.push({ value: 'search', label: 'Loki Search' });
}
}
return (
@ -106,7 +120,7 @@ class TempoQueryFieldComponent extends React.PureComponent<Props, State> {
<InlineField label="Query type">
<RadioButtonGroup<TempoQueryType>
options={queryTypeOptions}
value={query.queryType || DEFAULT_QUERY_TYPE}
value={query.queryType}
onChange={(v) =>
onChange({
...query,