This is an automated email from the ASF dual-hosted git repository.

jerrypeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 169534d  fix bugs in python metrics (#2928)
169534d is described below

commit 169534de5796ee9e31b79d1c0706f67571f19d5f
Author: Boyang Jerry Peng <jerry.boyang.p...@gmail.com>
AuthorDate: Mon Nov 5 10:59:44 2018 -0800

    fix bugs in python metrics (#2928)
---
 .../instance/src/main/python/python_instance.py      | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/pulsar-functions/instance/src/main/python/python_instance.py 
b/pulsar-functions/instance/src/main/python/python_instance.py
index fbcc74f..6f74461 100644
--- a/pulsar-functions/instance/src/main/python/python_instance.py
+++ b/pulsar-functions/instance/src/main/python/python_instance.py
@@ -104,15 +104,15 @@ class Stats(object):
     if len(self.latest_sys_exception) > 10:
       self.latest_sys_exception.pop(0)
 
-  def reset(self):
-    self.latest_user_exception.clear()
-    self.latest_sys_exception.clear()
-    self.stat_total_processed._value.set(0.0)
-    self.stat_total_processed_successfully._value.set(0.0)
-    self.stat_total_user_exceptions._value.set(0.0)
-    self.stat_total_sys_exceptions._value.set(0.0)
-    self.stats_process_latency_ms._sum.set(0)
-    self.stats_process_latency_ms._count.set(0);
+  def reset(self, metrics_labels):
+    self.latest_user_exception = []
+    self.latest_sys_exception = []
+    self.stat_total_processed.labels(*metrics_labels)._value.set(0.0)
+    
self.stat_total_processed_successfully.labels(*metrics_labels)._value.set(0.0)
+    self.stat_total_user_exceptions.labels(*metrics_labels)._value.set(0.0)
+    self.stat_total_sys_exceptions.labels(*metrics_labels)._value.set(0.0)
+    self.stats_process_latency_ms.labels(*metrics_labels)._sum.set(0)
+    self.stats_process_latency_ms.labels(*metrics_labels)._count.set(0);
     self.last_invocation_time = 0.0
 
 class PythonInstance(object):
@@ -321,7 +321,7 @@ class PythonInstance(object):
     return metrics
 
   def reset_metrics(self):
-    self.stats.reset()
+    self.stats.reset(self.metrics_labels)
     self.contextimpl.reset_metrics()
 
   def get_metrics(self):

Reply via email to