loki: query splitting: better stats (#64105)

pull/64127/head
Gábor Farkas 2 years ago committed by GitHub
parent ab512fcf88
commit 192308aac7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      public/app/plugins/datasource/loki/mocks.ts
  2. 15
      public/app/plugins/datasource/loki/queryUtils.test.ts
  3. 2
      public/app/plugins/datasource/loki/queryUtils.ts

@ -152,7 +152,7 @@ export function getMockFrames() {
],
meta: {
stats: [
{ displayName: 'Summary: total bytes processed', value: 11 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 11 },
{ displayName: 'Ingester: total reached', value: 1 },
],
},
@ -199,7 +199,7 @@ export function getMockFrames() {
],
meta: {
stats: [
{ displayName: 'Summary: total bytes processed', value: 22 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 22 },
{ displayName: 'Ingester: total reached', value: 2 },
],
},
@ -225,7 +225,7 @@ export function getMockFrames() {
meta: {
stats: [
{ displayName: 'Ingester: total reached', value: 1 },
{ displayName: 'Summary: total bytes processed', value: 11 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 11 },
],
},
length: 2,
@ -250,7 +250,7 @@ export function getMockFrames() {
meta: {
stats: [
{ displayName: 'Ingester: total reached', value: 2 },
{ displayName: 'Summary: total bytes processed', value: 22 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 22 },
],
},
length: 2,
@ -276,7 +276,7 @@ export function getMockFrames() {
meta: {
stats: [
{ displayName: 'Ingester: total reached', value: 2 },
{ displayName: 'Summary: total bytes processed', value: 33 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 33 },
],
},
length: 2,

@ -369,6 +369,7 @@ describe('combineResponses', () => {
stats: [
{
displayName: 'Summary: total bytes processed',
unit: 'decbytes',
value: 33,
},
],
@ -409,6 +410,7 @@ describe('combineResponses', () => {
stats: [
{
displayName: 'Summary: total bytes processed',
unit: 'decbytes',
value: 33,
},
],
@ -449,6 +451,7 @@ describe('combineResponses', () => {
stats: [
{
displayName: 'Summary: total bytes processed',
unit: 'decbytes',
value: 33,
},
],
@ -488,31 +491,31 @@ describe('combineResponses', () => {
it('two values', () => {
const responseA = makeResponse([
{ displayName: 'Ingester: total reached', value: 1 },
{ displayName: 'Summary: total bytes processed', value: 11 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 11 },
]);
const responseB = makeResponse([
{ displayName: 'Ingester: total reached', value: 2 },
{ displayName: 'Summary: total bytes processed', value: 22 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 22 },
]);
expect(combineResponses(responseA, responseB).data[0].meta.stats).toStrictEqual([
{ displayName: 'Summary: total bytes processed', value: 33 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 33 },
]);
});
it('one value', () => {
const responseA = makeResponse([
{ displayName: 'Ingester: total reached', value: 1 },
{ displayName: 'Summary: total bytes processed', value: 11 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 11 },
]);
const responseB = makeResponse();
expect(combineResponses(responseA, responseB).data[0].meta.stats).toStrictEqual([
{ displayName: 'Summary: total bytes processed', value: 11 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 11 },
]);
expect(combineResponses(responseB, responseA).data[0].meta.stats).toStrictEqual([
{ displayName: 'Summary: total bytes processed', value: 11 },
{ displayName: 'Summary: total bytes processed', unit: 'decbytes', value: 11 },
]);
});

@ -365,7 +365,7 @@ function getCombinedMetadataStats(
const sourceStat = sourceStats.find((s) => s.displayName === TOTAL_BYTES_STAT);
if (sourceStat != null && destStat != null) {
return [{ value: sourceStat.value + destStat.value, displayName: TOTAL_BYTES_STAT }];
return [{ value: sourceStat.value + destStat.value, displayName: TOTAL_BYTES_STAT, unit: destStat.unit }];
}
// maybe one of them exist

Loading…
Cancel
Save