report: migrate Event.Extra to Event.Contexts (sentry-go v0.46+ compat)#159
Open
denniszag wants to merge 1 commit intocockroachdb:masterfrom
Open
report: migrate Event.Extra to Event.Contexts (sentry-go v0.46+ compat)#159denniszag wants to merge 1 commit intocockroachdb:masterfrom
denniszag wants to merge 1 commit intocockroachdb:masterfrom
Conversation
sentry-go v0.46.0 removed the Extra field from sentry.Event (see getsentry/sentry-go#1274). ReportError merged its extraDetails map into event.Extra, which now fails to compile against sentry-go >= v0.46.0. Because report_api.go in the root errors package imports the report sub-package, the typecheck failure blocks the entire module for every downstream consumer -- not just callers of the Sentry reporting code. Switches the per-key merge to event.Contexts, which is the documented replacement. Each extra is stored under sentry.Context{"value": v} to conform to the Context schema (map[string]interface{}). Along the way: - Adds the new Close() and FlushWithContext(ctx) methods required by the v0.46.0 sentry.Transport interface on the test-only interceptingTransport in report/report_test.go and fmttests/datadriven_test.go. - In the fmttests printer, filters to only Contexts entries that carry our "value" sub-key, so Sentry's built-in default contexts (device/os/runtime/trace) emitted by sentry.NewEvent() do not leak into fixtures. Preserves the "== Extra" label -- net fixture diff is empty. - Fixes a pre-existing non-constant-format-string call in fmttests/datadriven_test.go flagged by the stricter go vet in the Go toolchain now required by sentry-go v0.46.0. - Bumps the go directive to 1.25.0 (drops the no-longer-needed toolchain line) because sentry-go v0.46.0 itself declares go 1.25.0. Fixes cockroachdb#158
There was a problem hiding this comment.
Pull request overview
Updates the Sentry reporting integration to compile with getsentry/sentry-go v0.46.0+ after the removal of sentry.Event.Extra, while keeping test fixtures stable.
Changes:
- Migrate Sentry “extra” payload merging from
Event.ExtratoEvent.Contexts(storing each value under a"value"sub-key). - Update report printers/tests to read from
Event.Contextsand filter out Sentry’s default contexts to avoid fixture churn. - Bump dependencies (notably
sentry-go→v0.46.0) and raise the modulegoversion to1.25.0; update test transports for newsentry.Transportmethods.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| report/report.go | Switch extra merge target from Event.Extra to Event.Contexts. |
| report/report_test.go | Read “error types” from Contexts and add new sentry.Transport methods to the test transport. |
| fmttests/datadriven_test.go | Keep fixtures stable by printing only "value"-wrapped contexts; fix vet issue in UnimplementedErrorf; update test transport interface methods. |
| go.mod | Upgrade sentry-go, raise go directive to 1.25.0, adjust deps. |
| go.sum | Dependency checksum updates for the module changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if event.Contexts == nil { | ||
| event.Contexts = make(map[string]sentry.Context) | ||
| } |
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.
Problem
sentry-go v0.46.0removed theExtrafield fromsentry.Event(getsentry/sentry-go#1274). The merge at
report/report.go:369writesevent.Extra[k] = vand no longer compiles. Becausereport_api.gointhe root
errorspackage imports thereportsub-package, the wholemodule fails to typecheck for every downstream consumer once they pick up
sentry-go >= v0.46.0.Fixes #158.
Change
report/report.go: replace theExtramerge withContexts; eachextra is stored as
sentry.Context{"value": v}to match theContextschema (
map[string]interface{}).report/report_test.go,fmttests/datadriven_test.go: read the newlocation in the test printers.
Collateral required to compile against sentry-go v0.46.0
sentry.TransportgainedClose()andFlushWithContext(ctx);implemented on the test-only
interceptingTransportin bothreport/report_test.goandfmttests/datadriven_test.go.sentry.NewEvent()now pre-populatesContextswith defaultdevice/os/runtime/traceentries (map-shaped, not{"value": …}). Thefmttestsprinter now filters to entries thatcarry a
"value"sub-key, so Sentry defaults don't leak intofixtures. Net fixture diff is zero — same
== Extra "<key>"output as before.
go.mod: bumpgetsentry/sentry-gotov0.46.0.godirective raised from1.23.0to1.25.0because sentry-gov0.46.0's own
go.moddeclaresgo 1.25.0. The redundanttoolchain go1.23.8line is dropped. This is forced by the upstreamdependency, not a preference; happy to split it out if the maintainers
prefer a separate "bump Go floor" PR first.
fmttests/datadriven_test.go: pre-existing non-constant format stringin a call to
issuelink.UnimplementedErrorf(...)was flagged by thestricter
go vetin the Go 1.25 toolchain and was blockinggo test;fixed with a
"%s"format specifier. Behaviour-preserving.Verification
go build ./...— clean.go test -race ./...— all packages pass except a pre-existingenvironmental failure in
withstack.TestReportableStackTracethatasserts stack frame filenames contain
/errors/or/errors@and sofails for any checkout located outside a path with
/errorsin it(same failure reproduces on untouched
upstream/master; unrelated tothis change).
fmttests/testdata/— zero diff; the-rewritepass produced nochanges thanks to the
"value"sub-key filter in the printer.Alternatives considered
Scope.SetContextinsideReportErrorinstead of merging intothe event directly. Cleaner in some ways, but breaks test code that
reads
event.Extra["error types"]afterBuildSentryReport— extraswould never land on the event. Chose direct
event.Contextsmerge topreserve the existing read-after-report pattern.
== Extralabel to== Context. Rejected tokeep fixture diffs empty; can be renamed in a follow-up.
preferred — just say the word and I'll rebase.
This change is