mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-21 05:44:54 +00:00
Attempting to collect queries for 1% of requests by using DEBUG.
This commit is contained in:
parent
b3b705dfe8
commit
a5cac63a74
2 changed files with 9 additions and 1 deletions
|
@ -45,12 +45,14 @@ class DBProfilerMiddleware:
|
||||||
random.random() < .01):
|
random.random() < .01):
|
||||||
request.activated_segments.append('db_profiler')
|
request.activated_segments.append('db_profiler')
|
||||||
connection.use_debug_cursor = True
|
connection.use_debug_cursor = True
|
||||||
|
settings.DEBUG = True
|
||||||
|
|
||||||
def process_celery(self):
|
def process_celery(self):
|
||||||
setattr(self, 'activated_segments', [])
|
setattr(self, 'activated_segments', [])
|
||||||
if random.random() < .01:
|
if random.random() < .01:
|
||||||
self.activated_segments.append('db_profiler')
|
self.activated_segments.append('db_profiler')
|
||||||
connection.use_debug_cursor = True
|
connection.use_debug_cursor = True
|
||||||
|
settings.DEBUG = True
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def process_exception(self, request, exception):
|
def process_exception(self, request, exception):
|
||||||
|
@ -134,10 +136,14 @@ class SQLLogToConsoleMiddleware:
|
||||||
'redis': sum([float(q['time']) for q in queries if q.get('redis')]),
|
'redis': sum([float(q['time']) for q in queries if q.get('redis')]),
|
||||||
}
|
}
|
||||||
setattr(request, 'sql_times_elapsed', times_elapsed)
|
setattr(request, 'sql_times_elapsed', times_elapsed)
|
||||||
|
|
||||||
|
settings.DEBUG = False
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def process_celery(self, profiler):
|
def process_celery(self, profiler):
|
||||||
self.process_response(profiler, None)
|
self.process_response(profiler, None)
|
||||||
|
settings.DEBUG = False
|
||||||
|
|
||||||
SIMPSONS_QUOTES = [
|
SIMPSONS_QUOTES = [
|
||||||
("Homer", "D'oh."),
|
("Homer", "D'oh."),
|
||||||
|
|
|
@ -184,7 +184,7 @@ class MStatistics(mongo.Document):
|
||||||
cls.objects(key=key).update_one(upsert=True, set__key=key, set__value=value)
|
cls.objects(key=key).update_one(upsert=True, set__key=key, set__value=value)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def collect_statistics_for_db(cls):
|
def collect_statistics_for_db(cls, debug=False):
|
||||||
lag = db_functions.mongo_max_replication_lag(settings.MONGODB)
|
lag = db_functions.mongo_max_replication_lag(settings.MONGODB)
|
||||||
cls.set('mongodb_replication_lag', lag)
|
cls.set('mongodb_replication_lag', lag)
|
||||||
|
|
||||||
|
@ -202,6 +202,8 @@ class MStatistics(mongo.Document):
|
||||||
for m in range(60):
|
for m in range(60):
|
||||||
minute = start_hours_ago + datetime.timedelta(minutes=m)
|
minute = start_hours_ago + datetime.timedelta(minutes=m)
|
||||||
key = "DB:%s:%s" % (db, minute.strftime('%s'))
|
key = "DB:%s:%s" % (db, minute.strftime('%s'))
|
||||||
|
if debug:
|
||||||
|
print(" -> %s:c" % key)
|
||||||
pipe.get("%s:c" % key)
|
pipe.get("%s:c" % key)
|
||||||
pipe.get("%s:t" % key)
|
pipe.get("%s:t" % key)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue