Give the structlog→Sentry payload a deep module#129
Merged
Conversation
Introduces StructuredLogPayload + STRUCTLOG_META_KEYS in logging_factory, owning the structlog log-line parse and meta-key vocabulary. Adds a round-trip drift net and a cross-reference comment at the producer chain. Sentry rewiring follows in a later task. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
enrich_sentry_event_from_structlog_log now owns only the Sentry-event-shape guards and delegates line-content interpretation to StructuredLogPayload.parse. IGNORED_STRUCTLOG_ATTRIBUTES is kept as a back-compat alias of STRUCTLOG_META_KEYS. Sentry tests slim to the three orchestration outcomes plus the skip-before-message ordering pin; the DES-4 regression moved to the value-object layer. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Promote the Logging↔Sentry integration write-up to name the StructuredLogPayload seam and STRUCTLOG_META_KEYS vocabulary, and add the change bundle (design + plan). Bundle status is approved; pr/outcome fill at merge time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Gives the structlog→Sentry log-line contract a single owner: a new
StructuredLogPayloadvalue object inlogging_factory.py. Itsparseclassmethod reconstructs a rendered structlog line intomessage/extra/skip_sentry, owning the meta-key vocabulary (STRUCTLOG_META_KEYS) and the meta-stripping internally. The Sentry instrument shrinks to orchestration — it keeps only the Sentry-event-shape guards and maps the parsed payload onto the event.Why
The contract was split between a serializer in
logging_factoryand a parser insentry_instrument, joined only by aformatted.startswith("{")sniff, with the meta-key set hand-maintained far from the chain that emits those keys. Rename a key or add a meta-processor and Sentry enrichment silently degraded, with no test crossing the producer's serializer and the consumer's parser together. (Surfaced as candidate 1 of the 2026-06-23 architecture review.)Changes
logging_factory.py— newStructuredLogPayload+STRUCTLOG_META_KEYS; a cross-reference comment attracer_injectioninlogging_instrument.py.sentry_instrument.py—enrich_sentry_event_from_structlog_lognow delegates toparse;IGNORED_STRUCTLOG_ATTRIBUTESretained as a silent back-compat alias ofSTRUCTLOG_META_KEYS.test_structured_log_payload.py(parse table + round-trip drift net, incl. the relocated DES-4 regression); Sentry tests slimmed to the three orchestration outcomes plus a skip-before-message ordering pin.architecture/instruments.mdandCLAUDE.mdname the seam; change bundle underplanning/changes/2026-06-23.01-structured-log-payload/.Verification
196 passed, 100% coverage;just lintclean (ruff+ty). Behavior preserved — the three Sentry outcomes and skip-before-message ordering are pinned.🤖 Generated with Claude Code