Patchwork D6526: tracing: add support for emitting counters

login
register
mail settings
Submitter phabricator
Date June 13, 2019, 2:17 a.m.
Message ID <differential-rev-PHID-DREV-d2fw5agvff3dzgtquxd4-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/40468/
State Superseded
Headers show

Comments

phabricator - June 13, 2019, 2:17 a.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6526

AFFECTED FILES
  hgdemandimport/tracing.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgdemandimport/tracing.py b/hgdemandimport/tracing.py
--- a/hgdemandimport/tracing.py
+++ b/hgdemandimport/tracing.py
@@ -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