New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Sentry logging #11

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@saulshanabrook

saulshanabrook commented Jan 19, 2013

Allow a worker to link to Sentry, based on a RQ_SENTRY_DNS settings. Based off of the RQ code for adding Sentry support.

saulshanabrook added some commits Jan 19, 2013

Added support for Sentry logging
Allow a worker to link to Sentry, based on a RQ_SENTRY_DNS settings. Based off of the [RQ code](rq/rq@ce1da3f) for adding Sentry support.
@selwin

This comment has been minimized.

Show comment
Hide comment
@selwin

selwin Jan 20, 2013

Collaborator

Hi there, thanks for the pull request. However, RQ 0.3.3 was just released a few days ago. The latest version replaced Logbook with Python's logging so Sentry should work without us needing to do anything special in django-rq.

As per Raven's documentation, you should be able to do add a logger for RQWorker like this:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'root': {
        'level': 'WARNING',
        'handlers': ['sentry'],
    },
    'handlers': {
        'sentry': {
            'level': 'ERROR',
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
        },
    },
    'loggers': {
        'worker': {
            'level': 'ERROR',
            'handlers': ['sentry'],
            'propagate': False,
        },
    },
}

My knowledge with regards to logging is rather limited, but I think the above should work. Please test it out and let me know if it works.

Collaborator

selwin commented Jan 20, 2013

Hi there, thanks for the pull request. However, RQ 0.3.3 was just released a few days ago. The latest version replaced Logbook with Python's logging so Sentry should work without us needing to do anything special in django-rq.

As per Raven's documentation, you should be able to do add a logger for RQWorker like this:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'root': {
        'level': 'WARNING',
        'handlers': ['sentry'],
    },
    'handlers': {
        'sentry': {
            'level': 'ERROR',
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
        },
    },
    'loggers': {
        'worker': {
            'level': 'ERROR',
            'handlers': ['sentry'],
            'propagate': False,
        },
    },
}

My knowledge with regards to logging is rather limited, but I think the above should work. Please test it out and let me know if it works.

@saulshanabrook

This comment has been minimized.

Show comment
Hide comment
@saulshanabrook

saulshanabrook Jan 20, 2013

Ok Ill check, if so then the problem is in the RQ documentation.

saulshanabrook commented Jan 20, 2013

Ok Ill check, if so then the problem is in the RQ documentation.

@saulshanabrook

This comment has been minimized.

Show comment
Hide comment
@saulshanabrook

saulshanabrook Jan 20, 2013

The Raven docs have this as an example, but I don't know much about logging either. I will try to see what works.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'root': {
        'level': 'WARNING',
        'handlers': ['sentry'],
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
    },
    'handlers': {
        'sentry': {
            'level': 'ERROR',
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'django.db.backends': {
            'level': 'ERROR',
            'handlers': ['console'],
            'propagate': False,
        },
        'raven': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
        'sentry.errors': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
    },
}

saulshanabrook commented Jan 20, 2013

The Raven docs have this as an example, but I don't know much about logging either. I will try to see what works.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'root': {
        'level': 'WARNING',
        'handlers': ['sentry'],
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
    },
    'handlers': {
        'sentry': {
            'level': 'ERROR',
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'django.db.backends': {
            'level': 'ERROR',
            'handlers': ['console'],
            'propagate': False,
        },
        'raven': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
        'sentry.errors': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
    },
}
@selwin

This comment has been minimized.

Show comment
Hide comment
@selwin

selwin Jan 21, 2013

Collaborator

@saulshanabrook I've confirmed that configuring rqworker's logging via LOGGING in settings.py is possible. The example below shows a logging configuration using RQ's standard console handler, all need to do is just change the handler to sentry:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "console": {
            "format": "%(asctime)s %(message)s",
            "datefmt": "%H:%M:%S",
        },
    },
    "handlers": {
        "console": {
            "level": "DEBUG",
            "class": "rq.utils.ColorizingStreamHandler",
            "formatter": "console",
            "exclude": ["%(asctime)s"],
        },
    },
    'loggers': {
        "rq.worker": {
            "handlers": ["console"],
            "level": "DEBUG" 
        },
    }
}
Collaborator

selwin commented Jan 21, 2013

@saulshanabrook I've confirmed that configuring rqworker's logging via LOGGING in settings.py is possible. The example below shows a logging configuration using RQ's standard console handler, all need to do is just change the handler to sentry:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "console": {
            "format": "%(asctime)s %(message)s",
            "datefmt": "%H:%M:%S",
        },
    },
    "handlers": {
        "console": {
            "level": "DEBUG",
            "class": "rq.utils.ColorizingStreamHandler",
            "formatter": "console",
            "exclude": ["%(asctime)s"],
        },
    },
    'loggers': {
        "rq.worker": {
            "handlers": ["console"],
            "level": "DEBUG" 
        },
    }
}

@selwin selwin closed this Jan 21, 2013

@saulshanabrook saulshanabrook deleted the saulshanabrook:patch-1 branch Jan 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment