|
|
|
@ -59,6 +59,7 @@ import { |
|
|
|
|
createTableFrameFromTraceQlQuery, |
|
|
|
|
} from './resultTransformer'; |
|
|
|
|
import { SearchQueryParams, TempoQuery, TempoJsonData } from './types'; |
|
|
|
|
import { getErrorMessage } from './utils'; |
|
|
|
|
|
|
|
|
|
export const DEFAULT_LIMIT = 20; |
|
|
|
|
|
|
|
|
@ -189,8 +190,8 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson |
|
|
|
|
data: [createTableFrameFromSearch(response.data.traces, this.instanceSettings)], |
|
|
|
|
}; |
|
|
|
|
}), |
|
|
|
|
catchError((error) => { |
|
|
|
|
return of({ error: { message: error.data.message }, data: [] }); |
|
|
|
|
catchError((err) => { |
|
|
|
|
return of({ error: { message: getErrorMessage(err.data.message) }, data: [] }); |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
@ -233,8 +234,8 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson |
|
|
|
|
data: createTableFrameFromTraceQlQuery(response.data.traces, this.instanceSettings), |
|
|
|
|
}; |
|
|
|
|
}), |
|
|
|
|
catchError((error) => { |
|
|
|
|
return of({ error: { message: error.data.message }, data: [] }); |
|
|
|
|
catchError((err) => { |
|
|
|
|
return of({ error: { message: getErrorMessage(err.data.message) }, data: [] }); |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
@ -264,8 +265,8 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson |
|
|
|
|
data: createTableFrameFromTraceQlQuery(response.data.traces, this.instanceSettings), |
|
|
|
|
}; |
|
|
|
|
}), |
|
|
|
|
catchError((error) => { |
|
|
|
|
return of({ error: { message: error.data.message }, data: [] }); |
|
|
|
|
catchError((err) => { |
|
|
|
|
return of({ error: { message: getErrorMessage(err.data.message) }, data: [] }); |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
@ -426,11 +427,19 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson |
|
|
|
|
method: 'GET', |
|
|
|
|
url: `${this.instanceSettings.url}/api/echo`, |
|
|
|
|
}; |
|
|
|
|
const response = await lastValueFrom(getBackendSrv().fetch(options)); |
|
|
|
|
|
|
|
|
|
if (response?.ok) { |
|
|
|
|
return { status: 'success', message: 'Data source is working' }; |
|
|
|
|
} |
|
|
|
|
return await lastValueFrom( |
|
|
|
|
getBackendSrv() |
|
|
|
|
.fetch(options) |
|
|
|
|
.pipe( |
|
|
|
|
mergeMap(() => { |
|
|
|
|
return of({ status: 'success', message: 'Data source successfully connected.' }); |
|
|
|
|
}), |
|
|
|
|
catchError((err) => { |
|
|
|
|
return of({ status: 'error', message: getErrorMessage(err.data.message, 'Unable to connect with Tempo') }); |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getQueryDisplayText(query: TempoQuery) { |
|
|
|
@ -522,7 +531,7 @@ function serviceMapQuery(request: DataQueryRequest<TempoQuery>, datasourceUid: s |
|
|
|
|
map((responses: DataQueryResponse[]) => { |
|
|
|
|
const errorRes = responses.find((res) => !!res.error); |
|
|
|
|
if (errorRes) { |
|
|
|
|
throw new Error(errorRes.error!.message); |
|
|
|
|
throw new Error(getErrorMessage(errorRes.error?.message)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const { nodes, edges } = mapPromMetricsToServiceMap(responses, request.range); |
|
|
|
@ -578,7 +587,7 @@ function rateQuery( |
|
|
|
|
map((responses: DataQueryResponse[]) => { |
|
|
|
|
const errorRes = responses.find((res) => !!res.error); |
|
|
|
|
if (errorRes) { |
|
|
|
|
throw new Error(errorRes.error!.message); |
|
|
|
|
throw new Error(getErrorMessage(errorRes.error?.message)); |
|
|
|
|
} |
|
|
|
|
return { |
|
|
|
|
data: [responses[0]?.data ?? [], serviceMapResponse.data[0], serviceMapResponse.data[1]], |
|
|
|
@ -633,7 +642,7 @@ function errorAndDurationQuery( |
|
|
|
|
map((errorAndDurationResponse: DataQueryResponse[]) => { |
|
|
|
|
const errorRes = errorAndDurationResponse.find((res) => !!res.error); |
|
|
|
|
if (errorRes) { |
|
|
|
|
throw new Error(errorRes.error!.message); |
|
|
|
|
throw new Error(getErrorMessage(errorRes.error?.message)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const serviceGraphView = getServiceGraphView( |
|
|
|
|