changeset 42477:e658ac39fe41

tracing: add support for emitting counters Differential Revision: https://phab.mercurial-scm.org/D6526
author Augie Fackler <augie@google.com>
date Wed, 12 Jun 2019 19:01:49 -0400
parents d0b8a3cfd732
children 561cd02c58ff
files hgdemandimport/tracing.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgdemandimport/tracing.py	Wed Jun 12 19:01:37 2019 -0400
+++ b/hgdemandimport/tracing.py	Wed Jun 12 19:01:49 2019 -0400
@@ -46,3 +46,13 @@
             _pipe.write('END %s %s\n' % (_session, whence))
         except IOError:
             pass
+
+def counter(label, amount, *labelargs):
+    if not _isactive():
+        return
+    l = label % labelargs
+    # See above in log() for why this is in a try/except.
+    try:
+        _pipe.write('COUNTER %s %d %s\n' % (_session, amount, l))
+    except IOError:
+        pass