Forward zap fields to Sentry instead of dropping them - #11
Merged
Conversation
Replace the hook-based Sentry integration with a custom zap core so error logs include structured fields from both logger context and call-site fields. The new core captures caller/stack metadata, keeps environment wiring, and improves exception values by including the `error` field when present.
BenHall-1
approved these changes
Sep 5, 2026
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.
Description
ZapSentryAdapterwas built onzapcore.RegisterHooks, whose callback receives a barezapcore.Entry— a type that carries no fields. Everyzap.String/zap.Uint64/zap.Errorattached to a log line was discarded before the event reached Sentry.The result is that a production error arrives as a message, a caller and a stack, and nothing else: no guild id, no table name, no SQLSTATE. That is most of what you need to diagnose it, and it affects every service using this adapter.
Reimplemented as a real
zapcore.Corethat carries fields from bothWith()and the call site into SentryExtra. When anerrorfield is present it is folded into the exception value so the underlying error shows in the event title rather than the generic log message.Checkmust add the wrapping core rather than the inner one, or zap writes straight through andWritenever runs.Type of Change
Testing
Get an error that logs in sentry, you should see the zap fields now
Checklist