mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: align exemplars check to latest api change (#32513)
This commit is contained in:
parent
37374bdecf
commit
d8a83fec9d
@ -510,6 +510,20 @@ describe('Prometheus Result Transformer', () => {
|
|||||||
expect(result[0].length).toBe(1);
|
expect(result[0].length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return with an empty array when data is empty', () => {
|
||||||
|
const result = transform(
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
status: 'success',
|
||||||
|
data: [],
|
||||||
|
},
|
||||||
|
} as any,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toHaveLength(0);
|
||||||
|
});
|
||||||
|
|
||||||
it('should remove exemplars that are too close to each other', () => {
|
it('should remove exemplars that are too close to each other', () => {
|
||||||
const response = {
|
const response = {
|
||||||
status: 'success',
|
status: 'success',
|
||||||
|
@ -63,7 +63,7 @@ export interface PromDataErrorResponse<T = PromData> {
|
|||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PromData = PromMatrixData | PromVectorData | PromScalarData | PromExemplarData[] | null;
|
export type PromData = PromMatrixData | PromVectorData | PromScalarData | PromExemplarData[];
|
||||||
|
|
||||||
export interface Labels {
|
export interface Labels {
|
||||||
[index: string]: any;
|
[index: string]: any;
|
||||||
@ -120,7 +120,7 @@ export function isExemplarData(result: PromData): result is PromExemplarData[] {
|
|||||||
if (result == null || !Array.isArray(result)) {
|
if (result == null || !Array.isArray(result)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return 'exemplars' in result[0];
|
return result.length ? 'exemplars' in result[0] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MatrixOrVectorResult = PromMatrixData['result'][0] | PromVectorData['result'][0];
|
export type MatrixOrVectorResult = PromMatrixData['result'][0] | PromVectorData['result'][0];
|
||||||
|
Loading…
Reference in New Issue
Block a user