From ec3f8ce04c7dd59d6cb1045560e5ec585c53bc71 Mon Sep 17 00:00:00 2001 From: Koenraad Verheyden Date: Thu, 27 May 2021 14:47:10 +0200 Subject: [PATCH] Tempo: Fix the test data source implementation (#34762) Fixes #32677 --- public/app/plugins/datasource/tempo/datasource.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/app/plugins/datasource/tempo/datasource.ts b/public/app/plugins/datasource/tempo/datasource.ts index 4fd53c63f5d..93c73e7b1e1 100644 --- a/public/app/plugins/datasource/tempo/datasource.ts +++ b/public/app/plugins/datasource/tempo/datasource.ts @@ -91,13 +91,19 @@ export class TempoDatasource extends DataSourceWithBackend { - 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) {