mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* Logs Volume: identify timeouts and provide remediation action * Supplementary result error: refactor updated component API * Create helper to identify timeout errors * Update timeout identifying function * Add unit test * Update panel unit test * Update public/app/features/explore/utils/logsVolumeResponse.ts Co-authored-by: Giordano Ricci <me@giordanoricci.com> * Use some instead of reduce * Change alert type to info * Add comment * Remove unnecessary optional chaining * Remove unnecessary condition * Remove unnecessary wrapping arrow function --------- Co-authored-by: Giordano Ricci <me@giordanoricci.com>
19 lines
594 B
TypeScript
19 lines
594 B
TypeScript
import { DataQueryError, DataQueryResponse } from '@grafana/data';
|
|
|
|
// Currently we can only infer if an error response is a timeout or not.
|
|
export function isTimeoutErrorResponse(response: DataQueryResponse | undefined): boolean {
|
|
if (!response) {
|
|
return false;
|
|
}
|
|
if (!response.error && !response.errors) {
|
|
return false;
|
|
}
|
|
|
|
const errors = response.error ? [response.error] : response.errors || [];
|
|
|
|
return errors.some((error: DataQueryError) => {
|
|
const message = `${error.message || error.data?.message}`?.toLowerCase();
|
|
return message.includes('timeout');
|
|
});
|
|
}
|