Skip to content

feat: stdlib logging to Logfire; Sentry for warning/error#129

Open
tomhamiltonstubber wants to merge 1 commit intomasterfrom
feat/logging-logfire-sentry
Open

feat: stdlib logging to Logfire; Sentry for warning/error#129
tomhamiltonstubber wants to merge 1 commit intomasterfrom
feat/logging-logfire-sentry

Conversation

@tomhamiltonstubber
Copy link
Copy Markdown
Member

Summary

Addresses the gap noted on PR #124: standard library logging was not reaching the Logfire pipeline (especially Celery workers, which never import main.py and therefore never ran dictConfig).

Changes

  • Logfire: When LOGFIRE_TOKEN is set, add logfire.LogfireLoggingHandler to the chronos and uvicorn loggers alongside the existing stream handlers.
  • Logger name: app_logger now uses chronos instead of base, so it is covered by the same dict config (and chronos.dispatcher still propagates to it).
  • Celery: In worker_process_init, call setup_logging() after Sentry/Logfire setup so worker and dispatcher logs are configured in every forked worker process.
  • Sentry: init_sentry() uses LoggingIntegration with event_level=WARNING so logger.warning, logger.error, and logger.exception produce Sentry events. Celery workers also get CeleryIntegration via init_sentry(for_celery_worker=True).
  • Web: init_sentry runs before importing views/worker so Sentry is ready before the app graph loads (Ruff E402 noqa on those imports).

Testing

  • uv run ruff check on touched files.

Made with Cursor

- Add LogfireLoggingHandler to chronos/uvicorn loggers when Logfire is configured
- Use chronos logger for app_logger so worker logs respect dictConfig
- Call setup_logging from Celery worker_process_init (workers never loaded main.py)
- init_sentry with LoggingIntegration (events for WARNING+) and CeleryIntegration on workers

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant