mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
008d0c82df
Summary: Rust based metrics so that even Rust libraries can write metrics. Reviewed By: quark-zju Differential Revision: D23577870 fbshipit-source-id: b19904968d9372c8ce19775fb37c7af53a370ea5
31 lines
789 B
Python
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
|