Added request profiler and a management command to purge profiler records.

- Legacy-Id: 17648
This commit is contained in:
Henrik Levkowetz 2020-04-15 20:48:08 +00:00
parent 1b94e10f4a
commit 78963ecdef
6 changed files with 44 additions and 1 deletions

View file

@ -60,3 +60,5 @@ $DTDIR/ietf/manage.py fetch_meeting_attendance --latest 2
# Send reminders originating from the review app
$DTDIR/ietf/bin/send-review-reminders
# Purge old request_profiler records
$DTDIR/ietf/manage.py purge_request_profiler_records

View file

@ -357,6 +357,9 @@ if DEBUG:
MIDDLEWARE = [
# Must be first to measure correct request timing
'request_profiler.middleware.ProfilingMiddleware',
#
'django.middleware.csrf.CsrfViewMiddleware',
'corsheaders.middleware.CorsMiddleware', # see docs on CORS_REPLACE_HTTPS_REFERER before using it
'django.middleware.common.CommonMiddleware',
@ -405,6 +408,7 @@ INSTALLED_APPS = [
'django_password_strength',
'djangobwr',
'form_utils',
'request_profiler',
'simple_history',
'tastypie',
'widget_tweaks',
@ -1118,9 +1122,10 @@ if SERVER_MODE != 'production':
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
#'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
#'LOCATION': '127.0.0.1:11211',
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
#'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'VERSION': __version__,
'KEY_PREFIX': 'ietf:dt',
},

View file

@ -34,3 +34,6 @@ DATABASES = {
if TEST_CODE_COVERAGE_CHECKER and not TEST_CODE_COVERAGE_CHECKER._started: # pyflakes:ignore
TEST_CODE_COVERAGE_CHECKER.start() # pyflakes:ignore
REQUEST_PROFILE_STORE_ANONYMOUS_SESSIONS = False

View file

@ -51,3 +51,5 @@ PHOTOS_DIR = MEDIA_ROOT + PHOTOS_DIRNAME # pyflakes:i
MIDDLEWARE = [ c for c in MIDDLEWARE if not c in DEV_MIDDLEWARE ] # pyflakes:ignore
TEMPLATES[0]['OPTIONS']['context_processors'] = [ p for p in TEMPLATES[0]['OPTIONS']['context_processors'] if not p in DEV_TEMPLATE_CONTEXT_PROCESSORS ] # pyflakes:ignore
REQUEST_PROFILE_STORE_ANONYMOUS_SESSIONS = False

View file

@ -0,0 +1,30 @@
# Copyright The IETF Trust 2020, All Rights Reserved
# -*- coding: utf-8 -*-
import datetime
from textwrap import dedent
from django.core.management.base import BaseCommand
import debug # pyflakes:ignore
from request_profiler.models import ProfilingRecord
class Command(BaseCommand):
"""
Purge information older than a given number of days (default 30) from the
profiling records table
"""
help = dedent(__doc__).strip()
def add_arguments(self, parser):
parser.add_argument('-d', '--days', dest='days', type=int, default=30,
help='Purge records older than this (default %(default)s days).')
def handle(self, *filenames, **options):
start = datetime.datetime.now() - datetime.timedelta(days=int(options['days']))
deleted = ProfilingRecord.objects.filter(start_ts__lt=start).delete()
self.stdout.write('deleted: %s' % str(deleted))

View file

@ -19,6 +19,7 @@ django-formtools>=1.0 # instead of django.contrib.formtools in 1.8
django-markup>=1.1
django-password-strength>=1.2.1
django-referrer-policy>=1.0
django-request-profiler==0.14 # 0.15 and above requires Django 2.x
django-simple-history>=2.3.0
django-stubs==1.3.0
django-tastypie>=0.13.2