Эх сурвалжийг харах

[desktop] Move oauth_authentication_time metric into liboauth

Erick Tryzelaar 10 жил өмнө
parent
commit
1302e34

+ 2 - 1
desktop/core/src/desktop/auth/backend.py

@@ -42,6 +42,7 @@ import pam
 from django_auth_ldap.backend import LDAPBackend
 import ldap
 from django_auth_ldap.config import LDAPSearch
+from liboauth.metrics import oauth_authentication_time
 
 
 LOG = logging.getLogger(__name__)
@@ -208,7 +209,7 @@ class OAuthBackend(DesktopBackendBase):
   build/env/bin/pip install httplib2
   """
 
-  @metrics.oauth_authentication_time
+  @oauth_authentication_time
   def authenticate(self, access_token):
     username = access_token['screen_name']
     password = access_token['oauth_token_secret']

+ 0 - 9
desktop/core/src/desktop/metrics.py

@@ -124,15 +124,6 @@ ldap_authentication_time = global_registry().timer(
     rate_denominator='seconds',
 )
 
-oauth_authentication_time = global_registry().timer(
-    name='auth.oauth.auth-time',
-    label='OAUTH Authentication Time',
-    description='The time spent waiting for OAUTH to authenticate a user',
-    numerator='seconds',
-    counter_numerator='authentications',
-    rate_denominator='seconds',
-)
-
 pam_authentication_time = global_registry().timer(
     name='auth.pam.auth-time',
     label='PAM Authentication Time',

+ 1 - 0
desktop/libs/liboauth/src/liboauth/__init__.py

@@ -15,3 +15,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import liboauth.metrics

+ 1 - 1
desktop/libs/liboauth/src/liboauth/backend.py

@@ -30,13 +30,13 @@ from django.contrib.auth.models import User
 from django.http import HttpResponseRedirect
 from django.utils.translation import ugettext as _
 
-from desktop import metrics
 from desktop.auth.backend import DesktopBackendBase
 from desktop.auth.backend import rewrite_user
 from useradmin.models import get_profile, get_default_user_group, UserProfile
 from hadoop.fs.exceptions import WebHdfsException
 
 import liboauth.conf
+import liboauth.metrics
 
 try:
   import oauth2 as oauth

+ 28 - 0
desktop/libs/liboauth/src/liboauth/metrics.py

@@ -0,0 +1,28 @@
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import absolute_import
+
+from desktop.lib.metrics import global_registry
+
+oauth_authentication_time = global_registry().timer(
+    name='auth.oauth.auth-time',
+    label='OAUTH Authentication Time',
+    description='The time spent waiting for OAUTH to authenticate a user',
+    numerator='seconds',
+    counter_numerator='authentications',
+    rate_denominator='seconds',
+)