Skip to content

Logging improvements #31

@khvn26

Description

@khvn26

1. Perform logging setup in the entrypoint, ahead of Django settings init

Currently, Flagsmith runs the logging setup during the Django settings initialisation.

However, as we're adding the new entrypoint taking care of the environment before Django is loaded, we want to emit logs before Django settings are initialised, while respecting the user-provided log settings (LOG_LEVEL, LOG_FORMAT and LOGGING_CONFIGURATION_FILE).

Solution: move logging initialisation to common.core.main.

2. Make structlog respect the JSON_FORMAT setting

Make sure the same set of JSON fields is maintained for structlog and stdlib.

Ideally, route the stdlib logs through structlog as well so the json processing is the same for both kinds of logs.

3. Improve the Sentry integration

  • Make sure that the exceptions logged with .exception()/.error(exc_info=True) show up in Sentry.
  • Ideally, send structlog event dict as Sentry context, and use some of the fields as tags.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions