Pārlūkot izejas kodu

[desktop] More metric cleanup

Erick Tryzelaar 10 gadi atpakaļ
vecāks
revīzija
e3168ee

+ 1 - 1
apps/useradmin/src/useradmin/metrics.py

@@ -25,7 +25,7 @@ def active_users():
 global_registry().gauge_callback(
     name='users.active',
     callback=active_users,
-    label='Number of Active Users',
+    label='Active Users',
     description='Number of users that were active in the last hour',
     numerator='users',
 )

+ 36 - 22
desktop/core/src/desktop/lib/metrics/registry.py

@@ -100,15 +100,25 @@ class MetricDefinition(object):
 
   def _make_json(self, key,
       suffix=None,
+      label_suffix=None,
+      description_suffix=None,
       **kwargs):
     names = ['hue', self.name.replace('.', '_').replace('-', '_')]
 
     label = self.label
     description = self.description
 
-    if suffix:
-      label += suffix
-      description += suffix
+    if label_suffix is None:
+      label_suffix = suffix
+
+    if description_suffix is None:
+      description_suffix = suffix
+
+    if label_suffix:
+      label += label_suffix
+
+    if description_suffix:
+      description += description_suffix
 
     if self._add_key_to_name:
       names.append(key)
@@ -157,17 +167,22 @@ class HistogramDefinition(MetricDefinition):
   def to_json(self):
     return [
         self._make_json('max',
-          suffix=': Max'),
+          label_suffix=': Max',
+          description_suffix=' over the life of the process: Max'),
         self._make_json('min',
-          suffix=': Min'),
+          label_suffix=': Min',
+          description_suffix=' over the life of the process: Min'),
         self._make_json('avg',
-          suffix=': Average'),
-        self._make_json('count',
-          suffix=': Samples',
+          label_suffix=': Average',
+          description_suffix=' over the life of the process: Average'),
+        self._make_json('sum',
+          label_suffix=': Samples',
+          description_suffix=' over the life of the process: Samples',
           counter=True,
           numeratorUnit=self.counter_numerator),
         self._make_json('std_dev',
-          suffix=': Standard Deviation'),
+          label_suffix=': Standard Deviation',
+          description_suffix=' over the life of the process: Standard Deviation'),
         self._make_json('median',
           suffix=': 50th Percentile'),
         self._make_json('75_percentile',
@@ -212,6 +227,8 @@ class MeterDefinition(MetricDefinition):
   def to_json(self):
     return [
         self._make_json('count',
+          label_suffix=': Samples',
+          description_suffix=' over the life of the process: Samples',
           counter=True,
           numeratorUnit=self.counter_numerator),
         self._make_json('15m_rate',
@@ -249,21 +266,22 @@ class TimerDefinition(MetricDefinition):
   def to_json(self):
     return [
         self._make_json('max',
-          suffix=': Max'),
+          label_suffix=': Max',
+          description_suffix=' over the life of the process: Max'),
         self._make_json('min',
-          suffix=': Min'),
+          label_suffix=': Min',
+          description_suffix=' over the life of the process: Min'),
         self._make_json('avg',
-          suffix=': Average'),
+          label_suffix=': Average',
+          description_suffix=' over the life of the process: Average'),
         self._make_json('sum',
-          suffix=': Samples',
+          label_suffix=': Samples',
+          description_suffix=' over the life of the process: Samples',
           counter=True,
           numeratorUnit=self.counter_numerator),
-        #self._make_json('count',
-        #  suffix=': Samples',
-        #  counter=True,
-        #  numeratorUnit=self.counter_numerator),
         self._make_json('std_dev',
-          suffix=': Standard Deviation'),
+          label_suffix=': Standard Deviation',
+          description_suffix=' over the life of the process: Standard Deviation'),
         self._make_json('1m_rate',
           suffix=': 1 Minute Rate',
           numeratorUnit=self.counter_numerator,
@@ -276,10 +294,6 @@ class TimerDefinition(MetricDefinition):
           suffix=': 15 Minue Rate',
           numeratorUnit=self.counter_numerator,
           denominatorUnit=self.rate_denominator),
-        #self._make_json('mean_rate',
-        #  suffix=': Mean Rate',
-        #  numeratorUnit=self.counter_numerator,
-        #  denominatorUnit=self.rate_denominator),
         self._make_json('median',
           suffix=': 50th Percentile'),
         self._make_json('75_percentile',

+ 11 - 21
desktop/core/src/desktop/metrics.py

@@ -27,41 +27,33 @@ from desktop.lib.metrics import global_registry
 global_registry().gauge_callback(
     name='python.threads.total',
     callback=lambda: len(threading.enumerate()),
-    label='Thread Count',
-    description='Number of threads',
+    label='Threads',
+    description='The total number of threads',
     numerator='threads',
 )
 
 global_registry().gauge_callback(
     name='python.threads.daemon',
     callback=lambda: sum(1 for thread in threading.enumerate() if thread.isDaemon()),
-    label='Daemon Thread Count',
-    description='Number of daemon threads',
+    label='Daemon Threads',
+    description='The number of daemon threads',
     numerator='threads',
 )
 
 # ------------------------------------------------------------------------------
 
 global_registry().gauge_callback(
-    name='python.multiprocessing.total',
+    name='python.multiprocessing',
     callback=lambda: len(multiprocessing.active_children()),
-    label='Process Count',
+    label='Multiprocessing Processes',
     description='Number of multiprocessing processes',
     numerator='processes',
 )
 
-global_registry().gauge_callback(
-    name='python.multiprocessing.active',
-    callback=lambda: sum(1 for proc in multiprocessing.active_children() if proc.is_alive()),
-    label='Active Multiprocessing Processes',
-    description='Number of active multiprocessing processes',
-    numerator='processes',
-)
-
 global_registry().gauge_callback(
     name='python.multiprocessing.daemon',
     callback=lambda: sum(1 for proc in multiprocessing.active_children() if proc.daemon),
-    label='Daemon Processes Count',
+    label='Daemon Multiprocessing Processes',
     description='Number of daemon multiprocessing processes',
     numerator='processes',
 )
@@ -75,7 +67,6 @@ for i in xrange(3):
       label='GC Object Count in Generation %s' % i,
       description='Total number of objects in garbage collection generation %s' % i,
       numerator='objects',
-      raw_counter=True,
   )
 
 global_registry().gauge_callback(
@@ -84,7 +75,6 @@ global_registry().gauge_callback(
     label='GC Object Count',
     description='Total number of objects in the Python process',
     numerator='objects',
-    raw_counter=True,
 )
 
 # ------------------------------------------------------------------------------
@@ -127,7 +117,7 @@ user_count = global_registry().gauge_callback(
 ldap_authentication_time = global_registry().timer(
     name='ldap.authentication-time',
     label='LDAP Authentication Time',
-    description='The time spent waiting for LDAP to authenticate a user over the life of the process',
+    description='The time spent waiting for LDAP to authenticate a user',
     numerator='seconds',
     counter_numerator='authentications',
     rate_denominator='seconds',
@@ -136,7 +126,7 @@ ldap_authentication_time = global_registry().timer(
 oauth_authentication_time = global_registry().timer(
     name='auth.oauth.authentication-time',
     label='OAUTH Authentication Time',
-    description='The time spent waiting for OAUTH to authenticate a user over the life of the process',
+    description='The time spent waiting for OAUTH to authenticate a user',
     numerator='seconds',
     counter_numerator='authentications',
     rate_denominator='seconds',
@@ -145,7 +135,7 @@ oauth_authentication_time = global_registry().timer(
 pam_authentication_time = global_registry().timer(
     name='auth.pam.authentication-time',
     label='PAM Authentication Time',
-    description='The time spent waiting for PAM to authenticate a user over the life of the process',
+    description='The time spent waiting for PAM to authenticate a user',
     numerator='seconds',
     counter_numerator='authentications',
     rate_denominator='seconds',
@@ -154,7 +144,7 @@ pam_authentication_time = global_registry().timer(
 spnego_authentication_time = global_registry().timer(
     name='auth.spnego.authentication-time',
     label='SPNEGO Authentication Time',
-    description='The time spent waiting for SPNEGO to authenticate a user over the life of the process',
+    description='The time spent waiting for SPNEGO to authenticate a user',
     numerator='seconds',
     counter_numerator='authentications',
     rate_denominator='seconds',

+ 1 - 1
desktop/libs/libopenid/src/libopenid/metrics.py

@@ -21,7 +21,7 @@ from desktop.lib.metrics import global_registry
 openid_authentication_time = global_registry().timer(
     name='openid.authentication-time',
     label='OpenID Authentication Time',
-    description='The time spent waiting for OpenID to authenticate a user over the life of the process',
+    description='The time spent waiting for OpenID to authenticate a user',
     numerator='seconds',
     counter_numerator='authentications',
     rate_denominator='seconds',

+ 1 - 1
desktop/libs/libsaml/src/libsaml/metrics.py

@@ -21,7 +21,7 @@ from desktop.lib.metrics import global_registry
 saml2_authentication_time = global_registry().timer(
     name='saml2.authentication-time',
     label='SAML2 Authentication Time',
-    description='The time spent waiting for SAML2 to authenticate a user over the life of the process',
+    description='The time spent waiting for SAML2 to authenticate a user',
     numerator='seconds',
     counter_numerator='authentications',
     rate_denominator='seconds',