From 38faebe31d3f0c5f4dcc8d772e028c44a35a2210 Mon Sep 17 00:00:00 2001 From: Tony Tung Date: Thu, 30 Jun 2016 13:59:40 -0700 Subject: [PATCH] [fastmanifest] the key of of the hit ratio should be the aggregating key Summary: If the key as always 'ratio', then all the ratios are aliased when we send off aggregate stats. That means we end up sending the last entry, rather than each individual entry. Test Plan: along with D3504940 run FB_HG_DIAGS= hg diff -c .: ``` "int": { "builddate": 1467289392, "cachehitratio": 100, "consumed": 489, "diffcachehitratio": -1, "elapsed": 280, "errorcode": 0, "filesnotincachehitratio": 0, "time": 1467318481 }, ``` Reviewers: lcharignon Reviewed By: lcharignon Subscribers: mitrandir, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3505464 Tasks: 12019647 Signature: t1:3505464:1467320144:327e0d306b9afa90ed9fc2d704a8ca02a79f3038 --- fastmanifest/metrics.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fastmanifest/metrics.py b/fastmanifest/metrics.py index b2f5e59d0d..25de023440 100644 --- a/fastmanifest/metrics.py +++ b/fastmanifest/metrics.py @@ -92,7 +92,7 @@ class metricscollector(object): def _addaggregatesamples(self): def _addhitratio(key, aggkey): # Aggregate the cache hit and miss to build a hit ratio - # store the ratio as aggkey : {ratio: ratio} in self.samples + # store the ratio as aggkey : {aggkey: ratio} in self.samples hit = len([s for s in self.samples if s[0] == key and s[1]["hit"]]) miss = len([s for s in self.samples @@ -102,7 +102,9 @@ class metricscollector(object): else: ratio=float(hit) * 100 / (miss + hit) - self.recordsample(aggkey, ratio=ratio) + data = { aggkey: ratio } + + self.recordsample(aggkey, **data) _addhitratio("cachehit", "cachehitratio") _addhitratio("diffcachehit", "diffcachehitratio")