Tempo: Fix the test data source implementation (#34762)

Fixes #32677
This commit is contained in:
Koenraad Verheyden 2021-05-27 14:47:10 +02:00 committed by GitHub
parent 006135c028
commit ec3f8ce04c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,13 +91,19 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TraceToLo
}
async testDatasource(): Promise<any> {
const response = await super.query({ targets: [{ query: '', refId: 'A' }] } as any).toPromise();
// to test Tempo we send a dummy traceID and verify Tempo answers with 'trace not found'
const response = await super.query({ targets: [{ query: '0' }] } as any).toPromise();
if (!response.error?.message?.startsWith('failed to get trace')) {
return { status: 'error', message: 'Data source is not working' };
const errorMessage = response.error?.message;
if (
errorMessage &&
errorMessage.startsWith('failed to get trace') &&
errorMessage.endsWith('trace not found in Tempo')
) {
return { status: 'success', message: 'Data source is working' };
}
return { status: 'success', message: 'Data source is working' };
return { status: 'error', message: 'Data source is not working' + (errorMessage ? `: ${errorMessage}` : '') };
}
getQueryDisplayText(query: TempoQuery) {