sapling/eden/scm/edenscm/mercurial/metrics.py
Stefan Filip 008d0c82df metrics: use the hgmetrics bindings for incrementing counters
Summary: Rust based metrics so that even Rust libraries can write metrics.

Reviewed By: quark-zju

Differential Revision: D23577870

fbshipit-source-id: b19904968d9372c8ce19775fb37c7af53a370ea5
2020-09-09 17:35:48 -07:00

31 lines
789 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
from bindings import hgmetrics
class metrics(object):
"""Abstract base class for metrics"""
def __init__(self, ui):
self.ui = ui
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:
hgmetrics.incrementcounter(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