Skip to content

ref(http): migrate frameworks to context scope API - #1401

Open
giortzisg wants to merge 1 commit into
scopes/http-integrationfrom
scopes/http-framework-integrations
Open

giortzisg wants to merge 1 commit into
scopes/http-integrationfrom
scopes/http-framework-integrations

Conversation

@giortzisg

Copy link
Copy Markdown
Contributor

Description

This migrates the remaining http frameworks to the new scopes API.

Issues

Changelog Entry Instructions

To add a custom changelog entry, uncomment the section above. Supports:

  • Single entry: just write text
  • Multiple entries: use bullet points
  • Nested bullets: indent 4+ spaces

For more details: custom changelog entries

Reminders

@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from 433dd31 to fd83eb2 Compare August 31, 2026 10:50
@giortzisg
giortzisg marked this pull request as ready for review August 31, 2026 10:52
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from fd83eb2 to bc477c9 Compare September 1, 2026 09:13
Comment thread _examples/iris/main.go
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from bc477c9 to 2ab55cc Compare September 1, 2026 12:16
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from 2ab55cc to 31e7e89 Compare September 1, 2026 12:57
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from 31e7e89 to 07a88ae Compare September 2, 2026 07:59
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from 07a88ae to 553f8ad Compare September 4, 2026 13:12
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from 553f8ad to 1f36c07 Compare September 4, 2026 13:26
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from 1f36c07 to 09507c7 Compare September 7, 2026 11:40
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from 09507c7 to f10271c Compare September 7, 2026 11:50

@szokeasaurusrex szokeasaurusrex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, some minor things

Comment thread echo/example_test.go Outdated
// Pass in the `.Context()` method from `*sentry.Span` struct.
// The `context.Context` instance inherits the context from `echo.Context`.
err := expensiveThing(sentrySpan.Context())
// Acquire the transaction from the request context. It may be nil if

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: should this say "span" rather than "transaction"?

Suggested change
// Acquire the transaction from the request context. It may be nil if
// Acquire the span from the request context. It may be nil if

Comment thread iris/sentryiris.go
context.WithValue(r.Context(), sentry.RequestContextKey, r),
err,
)
ctx := context.WithValue(r.Context(), sentry.RequestContextKey, r)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question I have: Given we reuse the same sentry.RequestContextKey for all server frameworks, is there a risk of collisions if a user uses two different server frameworks in the same app?

I suppose this would be an edge case but still perhaps worth handling gracefully

Comment on lines +426 to +451
func TestPanicHandlerFuncDoesNotReplaceRequest(t *testing.T) {
transport := &sentry.MockTransport{}
client, err := sentry.NewClient(sentry.ClientOptions{
Dsn: "http://whatever@example.com/1337",
Transport: transport,
})
if err != nil {
t.Fatal(err)
}
t.Cleanup(client.Close)

ctx := sentry.ContextWithClient(context.Background(), client)
request := httptest.NewRequest(http.MethodGet, "http://example.com/panic", nil).WithContext(ctx)
info := &negroni.PanicInformation{Request: request, RecoveredPanic: "test"}

sentrynegroni.PanicHandlerFunc(info)
if info.Request != request {
t.Fatal("PanicHandlerFunc replaced the caller's request")
}
if ok := client.Flush(testutils.FlushTimeout()); !ok {
t.Fatal("client flush timed out")
}
if got := len(transport.Events()); got != 1 {
t.Fatalf("captured events = %d, want 1", got)
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: This test seems to be mocking quite a lot; is there any way we could instead of creating a simulated PanicInformation actually induce a real panic and try to catch it? If not, I suppose this is a good alternative

@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from f10271c to 38db75f Compare September 16, 2026 09:14
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from 38db75f to d7c5a55 Compare September 17, 2026 08:38
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from d7c5a55 to f0f8c09 Compare September 17, 2026 09:09
Carry isolated request scopes and spans through native request contexts in Echo, Gin, Iris, and Negroni, and capture panics through the context-backed root API. Read all baggage header values and preserve existing caller contexts and transaction ownership when middleware is nested.

Echo, Gin, and Iris GetHubFromContext, SetHubOnContext, and GetSpanFromContext helpers are removed. Use sentry.ScopeFromContext and sentry.SpanFromContext with the framework request context.
@giortzisg
giortzisg removed this pull request from stack #1420 September 18, 2026 11:17
@giortzisg
giortzisg force-pushed the scopes/http-framework-integrations branch from f0f8c09 to f2279a0 Compare September 18, 2026 11:18
@giortzisg
giortzisg added this pull request to stack #1433 September 18, 2026 11:22
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.

2 participants