metrics: treat slash '/' as metric delimiter

Summary:
Slash is probably the standard metric delimiter nowadays. Since we don't have
that many metrics I think that it makes sense to look at slash as the
standard metric delimiter going forward.
This diff updates parsing of metric names to treat both '_' and '/' as
delimiters.

Reviewed By: quark-zju

Differential Revision: D23577876

fbshipit-source-id: 03997b1285df9c52d6e2837b5af5372deb69b133
This commit is contained in:
Stefan Filip 2020-09-09 17:32:44 -07:00 committed by Facebook GitHub Bot
parent 4ad9091598
commit ead17552cf

View File

@ -425,9 +425,10 @@ def dispatch(req):
# Re-arrange metrics so "a_b_c", "a_b_d", "a_c" becomes
# {'a': {'b': {'c': ..., 'd': ...}, 'c': ...}
metrics = {}
splitre = re.compile("_|/")
for key, value in ui.metrics.stats.items():
cur = metrics
names = key.split("_")
names = splitre.split(key)
for name in names[:-1]:
cur = cur.setdefault(name, {})
cur[names[-1]] = value