From 39bf4e407f62decbc9ad8796ae2f013c73b36db8 Mon Sep 17 00:00:00 2001 From: Jon Chase Date: Thu, 2 Feb 2017 15:10:03 -0500 Subject: [PATCH] adding 50_percentile to _get_histogram_metrics --- pyformance/registry.py | 1 + tests/test__carbon_reporter.py | 2 ++ tests/test__opentsdb_reporter.py | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pyformance/registry.py b/pyformance/registry.py index 6066a18..9e09f79 100644 --- a/pyformance/registry.py +++ b/pyformance/registry.py @@ -144,6 +144,7 @@ def _get_histogram_metrics(self, key): "max": histogram.get_max(), "min": histogram.get_min(), "std_dev": histogram.get_stddev(), + "50_percentile": snapshot.get_median(), "75_percentile": snapshot.get_75th_percentile(), "95_percentile": snapshot.get_95th_percentile(), "99_percentile": snapshot.get_99th_percentile(), diff --git a/tests/test__carbon_reporter.py b/tests/test__carbon_reporter.py index f6678e0..36f6627 100644 --- a/tests/test__carbon_reporter.py +++ b/tests/test__carbon_reporter.py @@ -78,6 +78,7 @@ def test_report_now_plain(self): 'hist.min 1 2', 'hist.95_percentile 512 2', 'hist.75_percentile 160.0 2', + 'hist.50_percentile 24.0 2', 'hist.std_dev 164.94851048466947 2' \ if PY3 else 'hist.std_dev 164.948510485 2', 'hist.max 512 2', @@ -123,6 +124,7 @@ def test_report_now_pickle(self): ('hist.min', (2, 1)), ('hist.95_percentile', (2, 512.0)), ('hist.75_percentile', (2, 160.0)), + ('hist.50_percentile', (2, 24.0)), ('hist.std_dev', (2, 164.94851048466947)), ('hist.max', (2, 512.0)), ('hist.avg', (2, 102.3)), diff --git a/tests/test__opentsdb_reporter.py b/tests/test__opentsdb_reporter.py index 8fee63a..cc3068b 100644 --- a/tests/test__opentsdb_reporter.py +++ b/tests/test__opentsdb_reporter.py @@ -33,7 +33,7 @@ def test_report_now(self): c2.dec() self.clock.add(1) output = r._collect_metrics(registry=self.registry) - self.assertEqual(len(output), 31) + self.assertEqual(len(output), 32) for data in output: assert data['metric'].startswith("prefix.")