[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
This commit is contained in:
Tony Tung 2016-06-30 13:59:40 -07:00
parent b75516fcff
commit 38faebe31d

View File

@ -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")