##// END OF EJS Templates
metrics: use prom metrics, and added some additional metrics
super-admin -
r4803:4c2bed55 default
parent child Browse files
Show More
@@ -179,7 +179,7 b' def exception_view(exc, request):'
179 179
180 180 statsd = request.registry.statsd
181 181 if statsd:
182 statsd.incr('rhodecode_exception', tags=["api"])
182 statsd.incr('rhodecode_exception_total', tags=["exc_source:api"])
183 183
184 184 return jsonrpc_error(request, fault_message, rpc_id)
185 185
@@ -296,9 +296,14 b' def request_view(request):'
296 296 # register some common functions for usage
297 297 attach_context_attributes(TemplateArgs(), request, request.rpc_user.user_id)
298 298
299 statsd = request.registry.statsd
300
299 301 try:
300 302 ret_value = func(**call_params)
301 return jsonrpc_response(request, ret_value)
303 resp = jsonrpc_response(request, ret_value)
304 if statsd:
305 statsd.incr('rhodecode_api_call_success_total')
306 return resp
302 307 except JSONRPCBaseError:
303 308 raise
304 309 except Exception:
@@ -308,9 +313,12 b' def request_view(request):'
308 313 id(exc_info), exc_info, prefix='rhodecode-api')
309 314 error_headers = [('RhodeCode-Exception-Id', str(exc_id)),
310 315 ('RhodeCode-Exception-Type', str(exc_type_name))]
311 return jsonrpc_error(
316 err_resp = jsonrpc_error(
312 317 request, retid=request.rpc_id, message='Internal server error',
313 318 headers=error_headers)
319 if statsd:
320 statsd.incr('rhodecode_api_call_fail_total')
321 return err_resp
314 322
315 323
316 324 def setup_request(request):
@@ -36,10 +36,10 b' from pyramid.threadlocal import get_curr'
36 36 from rhodecode.authentication.interface import IAuthnPluginRegistry
37 37 from rhodecode.authentication.schema import AuthnPluginSettingsSchemaBase
38 38 from rhodecode.lib import rc_cache
39 from rhodecode.lib.statsd_client import StatsdClient
39 40 from rhodecode.lib.auth import PasswordGenerator, _RhodeCodeCryptoBCrypt
40 41 from rhodecode.lib.utils2 import safe_int, safe_str
41 from rhodecode.lib.exceptions import LdapConnectionError, LdapUsernameError, \
42 LdapPasswordError
42 from rhodecode.lib.exceptions import (LdapConnectionError, LdapUsernameError, LdapPasswordError)
43 43 from rhodecode.model.db import User
44 44 from rhodecode.model.meta import Session
45 45 from rhodecode.model.settings import SettingsModel
@@ -780,12 +780,19 b' def authenticate(username, password, env'
780 780
781 781 log.debug('PLUGIN USER DATA: %s', plugin_user)
782 782
783 statsd = StatsdClient.statsd
784
783 785 if plugin_user:
784 786 log.debug('Plugin returned proper authentication data')
787 if statsd:
788 statsd.incr('rhodecode_login_success_total')
785 789 return plugin_user
790
786 791 # we failed to Auth because .auth() method didn't return proper user
787 792 log.debug("User `%s` failed to authenticate against %s",
788 793 display_user, plugin.get_id())
794 if statsd:
795 statsd.incr('rhodecode_login_fail_total')
789 796
790 797 # case when we failed to authenticate against all defined plugins
791 798 return None
@@ -182,7 +182,7 b' def error_handler(exception, request):'
182 182
183 183 statsd = request.registry.statsd
184 184 if statsd and base_response.status_code > 499:
185 statsd.incr('rhodecode_exception', tags=["code:{}".format(base_response.status_code)])
185 statsd.incr('rhodecode_exception_total', tags=["code:{}".format(base_response.status_code)])
186 186
187 187 error_explanation = base_response.explanation or str(base_response)
188 188 if base_response.status_code == 404:
@@ -74,7 +74,7 b' def run_task(task, *args, **kwargs):'
74 74 log.debug('executing task %s:%s in sync mode', 'TASK', task)
75 75
76 76 if statsd:
77 statsd.incr('rhodecode_celery_task', tags=[
77 statsd.incr('rhodecode_celery_task_total', tags=[
78 78 'task:{}'.format(task),
79 79 'mode:{}'.format(exec_mode)
80 80 ])
@@ -179,7 +179,7 b' def task_failure_signal('
179 179 store_exception(id(exc_info), exc_info, prefix='rhodecode-celery')
180 180 statsd = StatsdClient.statsd
181 181 if statsd:
182 statsd.incr('rhodecode_exception', tags=["celery"])
182 statsd.incr('rhodecode_exception_total', tags=["exc_source:celery"])
183 183
184 184 closer = celery_app.conf['PYRAMID_CLOSER']
185 185 if closer:
@@ -36,6 +36,7 b' from rhodecode.lib import audit_logger'
36 36 from rhodecode.lib.celerylib import get_logger, async_task, RequestContextTask, run_task
37 37 from rhodecode.lib import hooks_base
38 38 from rhodecode.lib.utils2 import safe_int, str2bool, aslist
39 from rhodecode.lib.statsd_client import StatsdClient
39 40 from rhodecode.model.db import (
40 41 Session, IntegrityError, true, Repository, RepoGroup, User)
41 42 from rhodecode.model.permission import PermissionModel
@@ -130,6 +131,9 b' def send_email(recipients, subject, body'
130 131 body=body, html=html_body,
131 132 extra_headers=extra_headers)
132 133 mailer.send_immediately(message)
134 statsd = StatsdClient.statsd
135 if statsd:
136 statsd.incr('rhodecode_email_sent_total')
133 137
134 138 except Exception:
135 139 log.exception('Mail sending failed')
@@ -222,7 +222,7 b' def post_pull(extras):'
222 222
223 223 statsd = StatsdClient.statsd
224 224 if statsd:
225 statsd.incr('rhodecode_pull')
225 statsd.incr('rhodecode_pull_total')
226 226
227 227 output = ''
228 228 # make lock is a tri state False, True, None. We only make lock on True
@@ -271,7 +271,7 b' def post_push(extras):'
271 271
272 272 statsd = StatsdClient.statsd
273 273 if statsd:
274 statsd.incr('rhodecode_push')
274 statsd.incr('rhodecode_push_total')
275 275
276 276 # Propagate to external components.
277 277 output = ''
@@ -53,7 +53,7 b' class RequestWrapperTween(object):'
53 53 _ver_ = rhodecode.__version__
54 54 _path = safe_str(get_access_path(request.environ))
55 55 _auth_user = self._get_user_info(request)
56
56 user_id = getattr(_auth_user, 'user_id', _auth_user)
57 57 total = time.time() - start
58 58 log.info(
59 59 'Req[%4s] %s %s Request to %s time: %.4fs [%s], RhodeCode %s',
@@ -64,19 +64,18 b' class RequestWrapperTween(object):'
64 64 statsd = request.registry.statsd
65 65 if statsd:
66 66 resp_code = response.status_code
67 user_id = getattr(_auth_user, 'user_id', _auth_user)
68 67 elapsed_time_ms = 1000.0 * total
69 68 statsd.timing(
70 69 'rhodecode_req_timing', elapsed_time_ms,
71 70 tags=[
72 #"path:{}".format(_path),
71 "view_name:{}".format(request.matched_route.name),
73 72 #"user:{}".format(user_id),
74 73 "code:{}".format(resp_code)
75 74 ]
76 75 )
77 76 statsd.incr(
78 'rhodecode_req_count', tags=[
79 #"path:{}".format(_path),
77 'rhodecode_req_count_total', tags=[
78 "view_name:{}".format(request.matched_route.name),
80 79 #"user:{}".format(user_id),
81 80 "code:{}".format(resp_code)
82 81 ])
General Comments 0
You need to be logged in to leave comments. Login now