grafana/public/app/features/explore/utils/logsVolumeResponse.ts
Matias Chomicki fb83414b6a
Logs Volume Timeouts: Add a custom message with options (retry, close) for request timeouts (#65434)
* 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>
2023-03-31 09:01:12 +00:00

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');
});
}