Add sentry_debug and sentry_ca_certs params (#1229)

Co-authored-by: pawel bak <p.bak@inteliclinic.com>
main
Paweł Bąk 5 years ago committed by GitHub
parent cfe389bd65
commit d914343e7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -195,6 +195,8 @@ def info(cli_config, interval, raw, only_queues, only_workers, by_queue, queues,
@click.option('--disable-job-desc-logging', is_flag=True, help='Turn off description logging.') @click.option('--disable-job-desc-logging', is_flag=True, help='Turn off description logging.')
@click.option('--verbose', '-v', is_flag=True, help='Show more output') @click.option('--verbose', '-v', is_flag=True, help='Show more output')
@click.option('--quiet', '-q', is_flag=True, help='Show less output') @click.option('--quiet', '-q', is_flag=True, help='Show less output')
@click.option('--sentry-ca-certs', envvar='RQ_SENTRY_CA_CERTS', help='Path to CRT file for Sentry DSN')
@click.option('--sentry-debug', envvar='RQ_SENTRY_DEBUG', help='Enable debug')
@click.option('--sentry-dsn', envvar='RQ_SENTRY_DSN', help='Report exceptions to this Sentry DSN') @click.option('--sentry-dsn', envvar='RQ_SENTRY_DSN', help='Report exceptions to this Sentry DSN')
@click.option('--exception-handler', help='Exception handler(s) to use', multiple=True) @click.option('--exception-handler', help='Exception handler(s) to use', multiple=True)
@click.option('--pid', help='Write the process ID number to a file at the specified path') @click.option('--pid', help='Write the process ID number to a file at the specified path')
@ -204,13 +206,16 @@ def info(cli_config, interval, raw, only_queues, only_workers, by_queue, queues,
@click.argument('queues', nargs=-1) @click.argument('queues', nargs=-1)
@pass_cli_config @pass_cli_config
def worker(cli_config, burst, logging_level, name, results_ttl, def worker(cli_config, burst, logging_level, name, results_ttl,
worker_ttl, job_monitoring_interval, disable_job_desc_logging, verbose, quiet, sentry_dsn, worker_ttl, job_monitoring_interval, disable_job_desc_logging,
exception_handler, pid, disable_default_exception_handler, max_jobs, with_scheduler, verbose, quiet, sentry_ca_certs, sentry_debug, sentry_dsn,
queues, log_format, date_format, **options): exception_handler, pid, disable_default_exception_handler, max_jobs,
with_scheduler, queues, log_format, date_format, **options):
"""Starts an RQ worker.""" """Starts an RQ worker."""
settings = read_config_file(cli_config.config) if cli_config.config else {} settings = read_config_file(cli_config.config) if cli_config.config else {}
# Worker specific default arguments # Worker specific default arguments
queues = queues or settings.get('QUEUES', ['default']) queues = queues or settings.get('QUEUES', ['default'])
sentry_ca_certs = sentry_ca_certs or settings.get('SENTRY_CA_CERTS')
sentry_debug = sentry_debug or settings.get('SENTRY_DEBUG')
sentry_dsn = sentry_dsn or settings.get('SENTRY_DSN') sentry_dsn = sentry_dsn or settings.get('SENTRY_DSN')
name = name or settings.get('NAME') name = name or settings.get('NAME')
@ -247,8 +252,12 @@ def worker(cli_config, burst, logging_level, name, results_ttl,
# Should we configure Sentry? # Should we configure Sentry?
if sentry_dsn: if sentry_dsn:
sentry_opts = {
"ca_certs": sentry_ca_certs,
"debug": sentry_debug
}
from rq.contrib.sentry import register_sentry from rq.contrib.sentry import register_sentry
register_sentry(sentry_dsn) register_sentry(sentry_dsn, **sentry_opts)
# if --verbose or --quiet, override --logging_level # if --verbose or --quiet, override --logging_level
if verbose or quiet: if verbose or quiet:

@ -3,10 +3,10 @@ from __future__ import (absolute_import, division, print_function,
unicode_literals) unicode_literals)
def register_sentry(sentry_dsn): def register_sentry(sentry_dsn, **opts):
"""Given a Raven client and an RQ worker, registers exception handlers """Given a Raven client and an RQ worker, registers exception handlers
with the worker so exceptions are logged to Sentry. with the worker so exceptions are logged to Sentry.
""" """
import sentry_sdk import sentry_sdk
from sentry_sdk.integrations.rq import RqIntegration from sentry_sdk.integrations.rq import RqIntegration
sentry_sdk.init(sentry_dsn, integrations=[RqIntegration()]) sentry_sdk.init(sentry_dsn, integrations=[RqIntegration()], **opts)

Loading…
Cancel
Save