فهرست منبع

[desktop] Simplifying metric names

Erick Tryzelaar 10 سال پیش
والد
کامیت
7865f67be5

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

@@ -141,17 +141,17 @@ class MetricDefinition(object):
 
 class CounterDefinition(MetricDefinition):
   def __init__(self, *args, **kwargs):
-    self.raw_counter = kwargs.pop('raw_counter', False)
+    self.treat_counter_as_gauge = kwargs.pop('treat_counter_as_gauge', False)
 
     super(CounterDefinition, self).__init__(*args, **kwargs)
 
-    assert not self.raw_counter or self.denominator is None, \
+    assert not self.treat_counter_as_gauge or self.denominator is None, \
         "Counters should not have denominators"
 
 
   def to_json(self):
     return [
-        self._make_json('count', counter=self.raw_counter),
+        self._make_json('count', counter=not self.treat_counter_as_gauge),
     ]
 
 
@@ -175,9 +175,14 @@ class HistogramDefinition(MetricDefinition):
         self._make_json('avg',
           label_suffix=': Average',
           description_suffix=' over the life of the process: Average'),
+        self._make_json('count',
+          label_suffix=': Sample Count',
+          description_suffix=' over the life of the process: Sample Count',
+          counter=True,
+          numeratorUnit=self.counter_numerator),
         self._make_json('sum',
-          label_suffix=': Samples',
-          description_suffix=' over the life of the process: Samples',
+          label_suffix=': Sample Sum',
+          description_suffix=' over the life of the process: Sample Sum',
           counter=True,
           numeratorUnit=self.counter_numerator),
         self._make_json('std_dev',
@@ -198,17 +203,17 @@ class HistogramDefinition(MetricDefinition):
 
 class GaugeDefinition(MetricDefinition):
   def __init__(self, *args, **kwargs):
-    self.raw_counter = kwargs.pop('raw_counter', False)
+    self.treat_gauge_as_counter = kwargs.pop('treat_gauge_as_counter', False)
 
     super(GaugeDefinition, self).__init__(*args, **kwargs)
 
-    assert not self.raw_counter or self.denominator is None, \
+    assert not self.treat_gauge_as_counter or self.denominator is None, \
         "Gauge metrics that are marked as counters cannot have a denominator"
 
 
   def to_json(self):
     return [
-        self._make_json('value', counter=self.raw_counter),
+        self._make_json('value', counter=self.treat_gauge_as_counter),
     ]
 
 
@@ -227,8 +232,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',
+          label_suffix=': Sample Sum',
+          description_suffix=' over the life of the process: Sample Sum',
           counter=True,
           numeratorUnit=self.counter_numerator),
         self._make_json('15m_rate',
@@ -274,9 +279,14 @@ class TimerDefinition(MetricDefinition):
         self._make_json('avg',
           label_suffix=': Average',
           description_suffix=' over the life of the process: Average'),
+        self._make_json('count',
+          label_suffix=': Sample Count',
+          description_suffix=' over the life of the process: Sample Count',
+          counter=True,
+          numeratorUnit=self.counter_numerator),
         self._make_json('sum',
-          label_suffix=': Samples',
-          description_suffix=' over the life of the process: Samples',
+          label_suffix=': Sample Sum',
+          description_suffix=' over the life of the process: Sample Sum',
           counter=True,
           numeratorUnit=self.counter_numerator),
         self._make_json('std_dev',

+ 5 - 4
desktop/core/src/desktop/metrics.py

@@ -84,6 +84,7 @@ active_requests = global_registry().counter(
     label='Active Requests',
     description='Number of currently active requests',
     numerator='requests',
+    treat_counter_as_gauge=True,
 )
 
 request_exceptions = global_registry().counter(
@@ -115,7 +116,7 @@ user_count = global_registry().gauge_callback(
 # ------------------------------------------------------------------------------
 
 ldap_authentication_time = global_registry().timer(
-    name='ldap.authentication-time',
+    name='auth.ldap.auth-time',
     label='LDAP Authentication Time',
     description='The time spent waiting for LDAP to authenticate a user',
     numerator='seconds',
@@ -124,7 +125,7 @@ ldap_authentication_time = global_registry().timer(
 )
 
 oauth_authentication_time = global_registry().timer(
-    name='auth.oauth.authentication-time',
+    name='auth.oauth.auth-time',
     label='OAUTH Authentication Time',
     description='The time spent waiting for OAUTH to authenticate a user',
     numerator='seconds',
@@ -133,7 +134,7 @@ oauth_authentication_time = global_registry().timer(
 )
 
 pam_authentication_time = global_registry().timer(
-    name='auth.pam.authentication-time',
+    name='auth.pam.auth-time',
     label='PAM Authentication Time',
     description='The time spent waiting for PAM to authenticate a user',
     numerator='seconds',
@@ -142,7 +143,7 @@ pam_authentication_time = global_registry().timer(
 )
 
 spnego_authentication_time = global_registry().timer(
-    name='auth.spnego.authentication-time',
+    name='auth.spnego.auth-time',
     label='SPNEGO Authentication Time',
     description='The time spent waiting for SPNEGO to authenticate a user',
     numerator='seconds',

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

@@ -19,7 +19,7 @@ from __future__ import absolute_import
 from desktop.lib.metrics import global_registry
 
 openid_authentication_time = global_registry().timer(
-    name='openid.authentication-time',
+    name='auth.openid.auth-time',
     label='OpenID Authentication Time',
     description='The time spent waiting for OpenID to authenticate a user',
     numerator='seconds',

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

@@ -19,7 +19,7 @@ from __future__ import absolute_import
 from desktop.lib.metrics import global_registry
 
 saml2_authentication_time = global_registry().timer(
-    name='saml2.authentication-time',
+    name='auth.saml2.auth-time',
     label='SAML2 Authentication Time',
     description='The time spent waiting for SAML2 to authenticate a user',
     numerator='seconds',