diff --git a/rhodecode/model/settings.py b/rhodecode/model/settings.py --- a/rhodecode/model/settings.py +++ b/rhodecode/model/settings.py @@ -19,9 +19,10 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import os +import re import hashlib import logging -import re +import time from collections import namedtuple from functools import wraps import bleach @@ -34,7 +35,7 @@ from rhodecode.lib.vcs.backends import b from rhodecode.lib.statsd_client import StatsdClient from rhodecode.model import BaseModel from rhodecode.model.db import ( - RepoRhodeCodeUi, RepoRhodeCodeSetting, RhodeCodeUi, RhodeCodeSetting, CacheKey) + RepoRhodeCodeUi, RepoRhodeCodeSetting, RhodeCodeUi, RhodeCodeSetting) from rhodecode.model.meta import Session @@ -256,11 +257,16 @@ class SettingsModel(BaseModel): } return settings + start = time.time() + result = _get_all_settings('rhodecode_settings', cache_key) + compute_time = time.time() - start + statsd = StatsdClient.statsd - with statsd.timer('rhodecode_settings_timing.histogram', auto_send=True) as tmr: - result = _get_all_settings('rhodecode_settings', cache_key) + if statsd: + elapsed_time_ms = round(1000.0 * compute_time) # use ms only + statsd.timing("rhodecode_settings_timing.histogram", elapsed_time_ms, + use_decimals=False) - compute_time = tmr.ms / 1000. log.debug('Fetching app settings for key: %s took: %.4fs', cache_key, compute_time) return result