From 3c271812f5a39bf3cbf0ab0b02a69fb6d2f6a66f Mon Sep 17 00:00:00 2001 From: adorda <adorda@boletinoficial.gob.ar> Date: Wed, 20 Feb 2019 11:49:37 -0300 Subject: [PATCH] APM y logger --- TsaApi/local_settings_dev.py | 14 +++++++++- TsaApi/local_settings_preprod.py | 8 +++++- TsaApi/local_settings_prod.py | 8 +++++- TsaApi/settings.py | 46 +++++++++++++++++++++++++------- requirements.txt | 3 ++- 5 files changed, 65 insertions(+), 14 deletions(-) diff --git a/TsaApi/local_settings_dev.py b/TsaApi/local_settings_dev.py index 16f6ae8..7a37026 100644 --- a/TsaApi/local_settings_dev.py +++ b/TsaApi/local_settings_dev.py @@ -48,6 +48,18 @@ GAS_PRICE = 1 SENTRY_URL = 'http://2ec54beaab3b4459a1e5afadea070f98:92aee3f5d91e4e66996a3e0792985541@172.17.30.21:9000/54' MEMCACHED_HOST = '172.17.0.1' -MEMCACHED_PORT = '11211' +MEMCACHED_PORT = 11211 # TIENE QUE SER INT PENDING_TXS_MEMCACHED_KEY = 'pending_txs' + +TEST_MEMCACHED_HOST = MEMCACHED_HOST +TEST_MEMCACHED_PORT = MEMCACHED_PORT + +TEST_PENDING_TXS_MEMCACHED_KEY = 'test_pending_txs' + +ELASTIC_APM = { + 'SERVICE_NAME': 'TsaApi-dev', + 'SERVER_URL': 'http://10.1.100.67:8200', + 'DEBUG': True, +} + diff --git a/TsaApi/local_settings_preprod.py b/TsaApi/local_settings_preprod.py index 3e45e9f..d76d3f6 100644 --- a/TsaApi/local_settings_preprod.py +++ b/TsaApi/local_settings_preprod.py @@ -32,4 +32,10 @@ PERMANENT_OTS_PREFIX = '1x' GAS = 250000 GAS_PRICE = 1 -SENTRY_URL = 'http://aa30f3ecd3bb4923a7046f197da61e07:47cd9f9ea1e243f6a9f47e2aa40b85c3@10.1.100.118:9000/82' \ No newline at end of file +SENTRY_URL = 'http://aa30f3ecd3bb4923a7046f197da61e07:47cd9f9ea1e243f6a9f47e2aa40b85c3@10.1.100.118:9000/82' + +ELASTIC_APM = { + 'SERVICE_NAME': 'TsaApi-pp', + 'SERVER_URL': 'http://10.20.99.87:8200', + 'DEBUG': True, +} diff --git a/TsaApi/local_settings_prod.py b/TsaApi/local_settings_prod.py index 1c6ab2c..b75500a 100644 --- a/TsaApi/local_settings_prod.py +++ b/TsaApi/local_settings_prod.py @@ -41,4 +41,10 @@ PERMANENT_OTS_PREFIX = '1x' GAS = 250000 GAS_PRICE = 1 -SENTRY_URL = 'http://36f4f241a007447d8a4441a13055b110:136cb6d1af854b869d13610603fa7321@10.1.100.118:9000/84' \ No newline at end of file +SENTRY_URL = 'http://36f4f241a007447d8a4441a13055b110:136cb6d1af854b869d13610603fa7321@10.1.100.118:9000/84' + +ELASTIC_APM = { + 'SERVICE_NAME': 'TsaApi', + 'SERVER_URL': 'http://10.20.99.87:8200', + 'DEBUG': False, +} diff --git a/TsaApi/settings.py b/TsaApi/settings.py index e658e4f..7b4aa32 100644 --- a/TsaApi/settings.py +++ b/TsaApi/settings.py @@ -24,11 +24,9 @@ import os import datetime import raven - # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ @@ -40,7 +38,6 @@ DEBUG = True ALLOWED_HOSTS = ['*'] - # Application definition INSTALLED_APPS = [ @@ -54,9 +51,12 @@ INSTALLED_APPS = [ 'raven.contrib.django.raven_compat', 'corsheaders', 'rest_framework_swagger', + 'elasticapm.contrib.django' + 'app' ] MIDDLEWARE = [ + 'elasticapm.contrib.django.middleware.TracingMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -89,7 +89,6 @@ TEMPLATES = [ WSGI_APPLICATION = 'TsaApi.wsgi.application' - # Database # https://docs.djangoproject.com/en/1.11/ref/settings/#databases @@ -100,7 +99,6 @@ DATABASES = { } } - # Password validation # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators @@ -125,6 +123,7 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'es' from django.utils.translation import ugettext_lazy as _ + LANGUAGES = ( ('es', _('Spanish')), ) @@ -141,14 +140,11 @@ USE_L10N = True USE_TZ = True - # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_URL = '/static/' - - # Habilitar para permitir la autenticación REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( @@ -164,10 +160,40 @@ REST_FRAMEWORK = { SENTRY_URL = 'http://2ec54beaab3b4459a1e5afadea070f98:92aee3f5d91e4e66996a3e0792985541@172.17.30.21:9000/54' MEMCACHED_HOST = '' -MEMCACHED_PORT = '' +MEMCACHED_PORT = 0 # OJO, TIENE QUE SER INT, sino REVIENTA MEMCACHED PENDING_TXS_MEMCACHED_KEY = 'pending_txs' +TEST_MEMCACHED_HOST = '' +TEST_MEMCACHED_PORT = '' + +TEST_PENDING_TXS_MEMCACHED_KEY = 'test_pending_txs' + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'file': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', + 'filename': '/path/to/django/debug.log', + }, + }, + 'loggers': { + 'django': { + 'handlers': ['file'], + 'level': 'DEBUG', + 'propagate': True, + }, + }, +} + +ELASTIC_APM = { + 'SERVICE_NAME' : 'TsaApi', + 'SERVER_URL': 'http://10.1.100.67:8200', + 'DEBUG': False, +} + try: from TsaApi.local_settings import * except ImportError as e: @@ -175,4 +201,4 @@ except ImportError as e: RAVEN_CONFIG = { 'dsn': SENTRY_URL, -} \ No newline at end of file +} diff --git a/requirements.txt b/requirements.txt index bb7f8e8..aaa7cba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -65,4 +65,5 @@ uritemplate==3.0.0 urllib3==1.23 wcwidth==0.1.7 web3==4.5.0 -websockets==5.0.1 \ No newline at end of file +websockets==5.0.1 +elastic-apm==3.0.0 \ No newline at end of file -- GitLab