sapling/eden/scm/edenscm/mercurial/metrics.py
Adam Simpkins ab3a7cb21f Move fb-mercurial sources into an eden/scm subdirectory.
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.
2019-11-13 16:04:48 -08:00

31 lines
809 B
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# metrics.py - generic metrics framework
from __future__ import absolute_import
class metrics(object):
"""Abstract base class for metrics"""
def __init__(self, ui):
self.ui = ui
self.stats = {}
def gauge(self, key, value=1, entity=None):
"""If entity is None, log locally. Otherwise, send it to a global counter."""
if entity is None:
self.stats.setdefault(key, 0)
self.stats[key] += value
def client(ui):
"""Returns the appropriate metrics module"""
# @fb-only: from . import fb
# @fb-only: return fb.fbmetrics(ui)
return metrics(ui) # @oss-only