Browse Source

Update librarie versions and add support for Sentry logging

master
Joshua Rubingh 4 months ago
parent
commit
964a817d8d
  1. 23
      agent.py
  2. 6
      env.example.txt
  3. 9
      requirements.txt

23
agent.py

@ -1,6 +1,8 @@
import logging
import logging.handlers
from logging.config import dictConfig, fileConfig
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
from pathlib import Path
import time
import glob
@ -67,8 +69,9 @@ else:
'class': 'agent.TimedCompressedRotatingFileHandler',
'formatter': 'f',
'filename': 'log/agent.log',
'when': 'midnight',
'interval' : 1,
'backupCount' : 3,
'level': logging.INFO}
},
root = {
@ -778,6 +781,21 @@ class VRE_API_CLient():
data = self._put_data(f'vrw/{id}/status/', data={'status' : 'TERMINATED', 'cloud_id' : cloud_id})
if __name__ == "__main__":
# Load config settings in a dict.
config = dotenv_values(f'{WORKINGDIR}/.env')
if '' != config.get('SENTRY_DSN',''):
# Load Sentry logging
# All of this is already happening by default!
sentry_logging = LoggingIntegration(
level=logging.INFO, # Capture info and above as breadcrumbs
event_level=logging.ERROR # Send errors as events
)
sentry_sdk.init(
dsn=config['SENTRY_DSN'],
integrations=[sentry_logging]
)
lockfile = Path(f'{WORKINGDIR}/.running')
if lockfile.exists():
@ -793,9 +811,6 @@ if __name__ == "__main__":
lockfile.write_text(str(os.getpid()))
# Load config settings in a dict.
config = dotenv_values(f'{WORKINGDIR}/.env')
# Load API call.
vre_api = VRE_API_CLient(config['VRE_API_HOST'], config['VRE_API_PREFIX'], config['VRE_API_USER'], config['VRE_API_PASS'])
if not vre_api.check_connection():

6
env.example.txt

@ -24,4 +24,8 @@ VRE_API_PASS=
# This will create the needed subgroups in a research group when set to 'True'.
# This is only needed for development, as in production, these subgroups will be created automatically.
# It could be that this can change in the future, so it is an option to create the needed subgroups in a research group
LDAP_MANUAL_GROUPS=False
LDAP_MANUAL_GROUPS=False
# Sentry settings
# Enter the full Sentry DSN string. This should contain a key and a project
SENTRY_DSN=

9
requirements.txt

@ -1,4 +1,5 @@
requests==2.25.1
ldap3==2.9
python-dotenv==0.18.0
python-slugify==5.0.2
requests==2.26.0
ldap3==2.9.1
python-dotenv==0.19.0
python-slugify==5.0.2
sentry-sdk==1.4.3
Loading…
Cancel
Save