From 189245652049b8bd5f89c8e4f86042060e5915ab Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Thu, 25 Oct 2018 17:38:18 +0800 Subject: [PATCH] fix: fix object set in collector --- .../metrics/src/collect/CompactMetricsCollector.ts | 10 +++++----- packages/metrics/src/collect/NormalMetricsCollector.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/metrics/src/collect/CompactMetricsCollector.ts b/packages/metrics/src/collect/CompactMetricsCollector.ts index 4db589e1..45d4fcbf 100644 --- a/packages/metrics/src/collect/CompactMetricsCollector.ts +++ b/packages/metrics/src/collect/CompactMetricsCollector.ts @@ -72,7 +72,7 @@ export class CompactMetricsCollector extends MetricsCollector { let totalCount = new BigNumber(); let totalRt = new BigNumber(); let successCount = new BigNumber(); - let hitCount = new BigNumber(-1); + let hitCount = new BigNumber(-1, -1); let countPerCategory = fastCompass.getMethodCountPerCategory(start); for (let [ key, value ] of countPerCategory.entries()) { @@ -80,13 +80,13 @@ export class CompactMetricsCollector extends MetricsCollector { this.addMetricWithSuffix(name, key + '_bucket_count', value.get(start).toString(), start, MetricObject.MetricType.DELTA, bucketInterval); - totalCount.add(value.get(start)); + totalCount = totalCount.add(value.get(start)); if ('success' === key) { - successCount.add(value.get(start)); + successCount = successCount.add(value.get(start)); } if ('hit' === key) { hitCount = value.get(start); - successCount.add(value.get(start)); + successCount = successCount.add(value.get(start)); } } else { this.addMetricWithSuffix(name, key + '_bucket_count', 0, start, @@ -96,7 +96,7 @@ export class CompactMetricsCollector extends MetricsCollector { for (let value of fastCompass.getMethodRtPerCategory(start).values()) { if (value.has(start)) { - totalRt.add(value.get(start)); + totalRt = totalRt.add(value.get(start)); } } this.addMetricWithSuffix(name, 'bucket_count', totalCount.toString(), start, diff --git a/packages/metrics/src/collect/NormalMetricsCollector.ts b/packages/metrics/src/collect/NormalMetricsCollector.ts index ce4cf5f4..873b7cfe 100644 --- a/packages/metrics/src/collect/NormalMetricsCollector.ts +++ b/packages/metrics/src/collect/NormalMetricsCollector.ts @@ -73,7 +73,7 @@ export class NormalMetricsCollector extends MetricsCollector { let totalCount = new BigNumber(); let totalRt = new BigNumber(); let successCount = new BigNumber(); - let hitCount = new BigNumber(-1); + let hitCount = new BigNumber(-1, -1); let countPerCategory = fastCompass.getMethodCountPerCategory(start); for (let [ key, value ] of countPerCategory.entries()) { @@ -81,13 +81,13 @@ export class NormalMetricsCollector extends MetricsCollector { this.addMetricWithSuffix(name, key + '_bucket_count', value.get(start).toString(), start, MetricObject.MetricType.DELTA, bucketInterval); - totalCount.add(value.get(start)); + totalCount = totalCount.add(value.get(start)); if ('success' === key) { - successCount.add(value.get(start)); + successCount = successCount.add(value.get(start)); } if ('hit' === key) { hitCount = value.get(start); - successCount.add(value.get(start)); + successCount = successCount.add(value.get(start)); } } else { this.addMetricWithSuffix(name, key + '_bucket_count', 0, start, @@ -97,7 +97,7 @@ export class NormalMetricsCollector extends MetricsCollector { for (let value of fastCompass.getMethodRtPerCategory(start).values()) { if (value.has(start)) { - totalRt.add(value.get(start)); + totalRt = totalRt.add(value.get(start)); } } this.addMetricWithSuffix(name, 'bucket_count', totalCount.toString(), start,