From 1eade5197f955b58f28040afd54b609647aa3e1a Mon Sep 17 00:00:00 2001 From: Rinish Sam <36656347+CaptainIRS@users.noreply.github.com> Date: Mon, 10 Oct 2022 14:15:59 +0530 Subject: [PATCH] Fix calculation and doc comment in prometheus observer (#1456) * Fixed histogram calculation * Fixed doc comment in test utility class Signed-off-by: CaptainIRS <36656347+CaptainIRS@users.noreply.github.com> Signed-off-by: CaptainIRS <36656347+CaptainIRS@users.noreply.github.com> --- .../lib/worker/tx-observers/prometheus-push-tx-observer.js | 4 ++-- .../lib/worker/tx-observers/prometheus-tx-observer.js | 4 ++-- .../test/worker/tx-observers/prometheus-push-tx-observer.js | 2 +- .../test/worker/tx-observers/prometheus-tx-observer.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/caliper-core/lib/worker/tx-observers/prometheus-push-tx-observer.js b/packages/caliper-core/lib/worker/tx-observers/prometheus-push-tx-observer.js index 3cbb4d7da..972c565f9 100644 --- a/packages/caliper-core/lib/worker/tx-observers/prometheus-push-tx-observer.js +++ b/packages/caliper-core/lib/worker/tx-observers/prometheus-push-tx-observer.js @@ -167,12 +167,12 @@ class PrometheusPushTxObserver extends TxObserverInterface { for (const result of results) { // pass/fail status from result.GetStatus() this.counterTxFinished.labels(result.GetStatus()).inc(); - this.histogramLatency.labels(result.GetStatus()).observe(result.GetTimeFinal() - result.GetTimeCreate()); + this.histogramLatency.labels(result.GetStatus()).observe((result.GetTimeFinal() - result.GetTimeCreate()) / 1000); } } else { // pass/fail status from result.GetStatus() this.counterTxFinished.labels(results.GetStatus()).inc(); - this.histogramLatency.labels(results.GetStatus()).observe((results.GetTimeFinal() - results.GetTimeCreate())/1000); + this.histogramLatency.labels(results.GetStatus()).observe((results.GetTimeFinal() - results.GetTimeCreate()) / 1000); } } diff --git a/packages/caliper-core/lib/worker/tx-observers/prometheus-tx-observer.js b/packages/caliper-core/lib/worker/tx-observers/prometheus-tx-observer.js index 6125fbf1e..eb9571f85 100644 --- a/packages/caliper-core/lib/worker/tx-observers/prometheus-tx-observer.js +++ b/packages/caliper-core/lib/worker/tx-observers/prometheus-tx-observer.js @@ -165,12 +165,12 @@ class PrometheusTxObserver extends TxObserverInterface { for (const result of results) { // pass/fail status from result.GetStatus() this.counterTxFinished.labels(result.GetStatus()).inc(); - this.histogramLatency.labels(result.GetStatus()).observe(result.GetTimeFinal() - result.GetTimeCreate()); + this.histogramLatency.labels(result.GetStatus()).observe((result.GetTimeFinal() - result.GetTimeCreate()) / 1000); } } else { // pass/fail status from result.GetStatus() this.counterTxFinished.labels(results.GetStatus()).inc(); - this.histogramLatency.labels(results.GetStatus()).observe((results.GetTimeFinal() - results.GetTimeCreate())/1000); + this.histogramLatency.labels(results.GetStatus()).observe((results.GetTimeFinal() - results.GetTimeCreate()) / 1000); } } } diff --git a/packages/caliper-core/test/worker/tx-observers/prometheus-push-tx-observer.js b/packages/caliper-core/test/worker/tx-observers/prometheus-push-tx-observer.js index ad6767a45..2368cf296 100644 --- a/packages/caliper-core/test/worker/tx-observers/prometheus-push-tx-observer.js +++ b/packages/caliper-core/test/worker/tx-observers/prometheus-push-tx-observer.js @@ -36,7 +36,7 @@ class Utils { /** * - * @return {boolean} the fake path + * @return {boolean} if the process is a forked process */ static isForkedProcess() { return false; diff --git a/packages/caliper-core/test/worker/tx-observers/prometheus-tx-observer.js b/packages/caliper-core/test/worker/tx-observers/prometheus-tx-observer.js index e5585e8a3..08b1ac67d 100644 --- a/packages/caliper-core/test/worker/tx-observers/prometheus-tx-observer.js +++ b/packages/caliper-core/test/worker/tx-observers/prometheus-tx-observer.js @@ -36,7 +36,7 @@ class Utils { /** * - * @return {boolean} the fake path + * @return {boolean} if the process is a forked process */ static isForkedProcess() { return false;