Skip to content

fix: preserve request attributes on shared log records - #58

Draft
Kayvan-Zahiri wants to merge 1 commit into
logtail:masterfrom
Kayvan-Zahiri:codex/preserve-shared-log-record-request
Draft

Kayvan-Zahiri wants to merge 1 commit into
logtail:masterfrom
Kayvan-Zahiri:codex/preserve-shared-log-record-request

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Problem

When a Django-style request object (or None) is attached to a LogRecord, create_frame deletes the request attribute from the record itself. The same record is passed to other Python logging handlers, so Better Stack's formatter or handler can prevent subsequent handlers from accessing their request context.

Change

Move the existing request-type filter into _parse_custom_events. Unsupported request values are still omitted from Better Stack output, while the original record remains intact. The existing allowlist and include_extra_attributes behavior are preserved.

Fixes #57.

Validation

  • Before: 4 failing regression tests, 2 passing control tests. Public formatter tests exercise a real logger with a subsequent capturing handler; public handler tests inspect the queue without starting transport. Controls cover all six supported request value types through each API.
  • After: repository CI test command nosetests --with-coverage --cover-branches --cover-package=logtail — 65 tests passed, 96% total branch-aware coverage.
  • SDK MyPy — 9 source files pass; strict public API consumer check — 1 file passes.
  • Compile checks and git diff --check pass.
  • Python 3.12 only; full supported Python-version matrix not run.
  • The suite prints an ignored at-fork callback diagnostic involving an existing mocked uploader function without reset; reproduced on unchanged upstream without the new tests (59 tests pass). No change to fork/upload handling here.
  • Local synthetic request objects and mocked ingestion only; no real request data, hosted account, credentials, paid resources, or UI automation.

AI assistance: OpenAI Codex investigated, implemented, tested, and prepared this draft. Human verification is not claimed.

This branch has not been deployed

No deployments
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.

Formatter deletes request attribute from shared LogRecord

1 participant