structlog_sentry_logger.structlog_sentry

Fork of structlog-sentry which adds full type information.

  • Necessary for proper Mypyc C extension compilation.

  • Will directly depend on structlog-sentry once associated PR is merged upstream

(see: kiwicom/structlog-sentry#44).

Module Contents

Classes

SentryBreadcrumbJsonProcessor

JSON Processor which logs breadcrumbs to Sentry.

SentryJsonProcessor

Sentry processor for structlog which uses JSONRenderer.

SentryProcessor

Sentry processor for structlog.

class structlog_sentry_logger.structlog_sentry.SentryBreadcrumbJsonProcessor(breadcrumb_level=logging.INFO, level=logging.WARNING, active=True, as_extra=True, tag_keys=None)

Bases: SentryJsonProcessor

Inheritance diagram of structlog_sentry_logger.structlog_sentry.SentryBreadcrumbJsonProcessor

JSON Processor which logs breadcrumbs to Sentry.

Addresses: SentryJsonProcessor breaks logging breadcrumbs #25 (source).

Initializes a structlog processor to handle Sentry events in JSON logs and include breadcrumbs.

Parameters:
active
breadcrumb_level
level
tag_keys
static save_breadcrumb(logger, event_dict)

Saves logging breadcrumbs for Sentry events.

Parameters:
  • logger (Any)

  • event_dict (structlog.types.EventDict)

Return type:

None

class structlog_sentry_logger.structlog_sentry.SentryJsonProcessor(level=logging.WARNING, active=True, as_extra=True, tag_keys=None)

Bases: SentryProcessor

Inheritance diagram of structlog_sentry_logger.structlog_sentry.SentryJsonProcessor

Sentry processor for structlog which uses JSONRenderer.

Uses Sentry SDK to capture events in Sentry.

Initializes a structlog processor to handle Sentry events in JSON logs.

Parameters:
active
level
tag_keys
class structlog_sentry_logger.structlog_sentry.SentryProcessor(level=logging.WARNING, active=True, as_extra=True, tag_keys=None, ignore_loggers=None)

Sentry processor for structlog.

Uses Sentry SDK to capture events in Sentry.

Initializes a structlog processor to handle Sentry events.

Parameters:
  • level (int) – events of this or higher levels will be reported to Sentry.

  • active (bool) – a flag to make this processor enabled/disabled.

  • as_extra (bool) – send event_dict as extra info to Sentry.

  • tag_keys (list[str] | str | None) – a list of keys. If any if these keys appear in event_dict, the key and its corresponding value in event_dict will be used as Sentry event tags. use “__all__” to report all key/value pairs of event as tags.

  • ignore_loggers (Iterable[str] | None) – a list of logger names to ignore any events from.

active
level
tag_keys