From 6e3d7cb48fbe6d29face5b7f5742bfd8172fca56 Mon Sep 17 00:00:00 2001 From: Vishwakant Mishra Date: Thu, 7 May 2026 01:58:35 +0530 Subject: [PATCH 1/2] Adding example of Summary metric --- CHANGELOG.md | 1 + example/summary.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 example/summary.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 057e81fb..8e7640e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ project adheres to [Semantic Versioning](http://semver.org/). - Expanded benchmarking code - new WorkerRegistry to provide equivalent support to AggregatorRegistry +- Added example for Summary metric ## [15.1.3] - 2024-06-27 diff --git a/example/summary.js b/example/summary.js new file mode 100644 index 00000000..08efcc46 --- /dev/null +++ b/example/summary.js @@ -0,0 +1,66 @@ +'use strict'; + +// Summary +// Single Label +// Multiple Values + +const { Summary, register } = require('..'); + +async function main() { + const summ = new Summary({ + name: 'test_summary', + help: 'Example of summary', + labelNames: ['code'], + percentiles: [0.5, 0.9, 0.99], + }); + + summ.observe({ code: '200' }, 0.7); + summ.observe({ code: '200' }, 0.1); + summ.observe({ code: '400' }, 1.5); + summ.observe({ code: '500' }, 2.2); + + console.log(await register.metrics()); + /* + # HELP test_summary Example of summary + # TYPE test_summary summary + test_summary{quantile="0.5",code="200"} 0.4 + test_summary{quantile="0.9",code="200"} 0.7 + test_summary{quantile="0.99",code="200"} 0.7 + test_summary_sum{code="200"} 0.7999999999999999 + test_summary_count{code="200"} 2 + test_summary{quantile="0.5",code="400"} 1.5 + test_summary{quantile="0.9",code="400"} 1.5 + test_summary{quantile="0.99",code="400"} 1.5 + test_summary_sum{code="400"} 1.5 + test_summary_count{code="400"} 1 + test_summary{quantile="0.5",code="500"} 2.2 + test_summary{quantile="0.9",code="500"} 2.2 + test_summary{quantile="0.99",code="500"} 2.2 + test_summary_sum{code="500"} 2.2 + test_summary_count{code="500"} 1 + */ + + summ.observe({ code: '200' }, 0.4); + console.log(await register.metrics()); + /* + # HELP test_summary Example of summary + # TYPE test_summary summary + test_summary{quantile="0.5",code="200"} 0.4 + test_summary{quantile="0.9",code="200"} 0.7 + test_summary{quantile="0.99",code="200"} 0.7 + test_summary_sum{code="200"} 1.2 + test_summary_count{code="200"} 3 + test_summary{quantile="0.5",code="400"} 1.5 + test_summary{quantile="0.9",code="400"} 1.5 + test_summary{quantile="0.99",code="400"} 1.5 + test_summary_sum{code="400"} 1.5 + test_summary_count{code="400"} 1 + test_summary{quantile="0.5",code="500"} 2.2 + test_summary{quantile="0.9",code="500"} 2.2 + test_summary{quantile="0.99",code="500"} 2.2 + test_summary_sum{code="500"} 2.2 + test_summary_count{code="500"} 1 + */ +} + +main(); From 92afb2343fa16888483e70bff9d6bdd37bb2d394 Mon Sep 17 00:00:00 2001 From: Jason Marshall Date: Tue, 30 Jun 2026 18:46:03 -0700 Subject: [PATCH 2/2] Verbage ... and build trigger --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7640e3..551db38d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ project adheres to [Semantic Versioning](http://semver.org/). - Expanded benchmarking code - new WorkerRegistry to provide equivalent support to AggregatorRegistry -- Added example for Summary metric +- Added examples for Summary metric ## [15.1.3] - 2024-06-27