feat(echo): add support for Echo v5#1183
Open
Scorfly wants to merge 1 commit intogetsentry:masterfrom
Open
Conversation
BREAKING CHANGE: echo integration now requires github.com/labstack/echo/v5
and Go 1.25. Echo v4 is no longer supported.
## Dependency and module
- Bump github.com/labstack/echo from v4.10.1 to v5.0.0.
- Set go directive to 1.25.0 in echo/go.mod.
- Drop Echo v4-only indirects (gommon, go-colorable, go-isatty,
bytebufferpool, fasttemplate, x/crypto, x/net) and update remaining
(x/sys, x/text). go.sum updated accordingly.
## Echo v5 API adjustments
- Use *echo.Context instead of echo.Context in handler and public API
(GetHubFromContext, SetHubOnContext, GetSpanFromContext) to match
v5’s pointer-based Context.
- Update all handler signatures in code and docs from
`func(c echo.Context) error` to `func(c *echo.Context) error`.
- In v5, Context.Response() returns http.ResponseWriter, not *Response,
so ctx.Response().Status is no longer available.
## HTTP status and Response handling
- Replace direct ctx.Response().Status with echo.UnwrapResponse(ctx.Response())
to obtain *echo.Response and use resp.Status when UnwrapResponse succeeds
and resp.Status != 0.
- When UnwrapResponse fails (e.g. middleware replaces the response with a
writer that does not unwrap to *echo.Response), leave status at its zero
value (0) instead of defaulting to 200.
- For handler-returned errors, use echo.HTTPStatusCoder instead of
*echo.HTTPError so that both *HTTPError and unexported *httpError
(ErrNotFound, ErrMethodNotAllowed, etc.) are handled and the correct
status is used for the transaction.
## Tests
- In TestIntegration, skip route registration when Handler is nil so the
“404 / no route” case does not call router.GET("", nil). Echo v5’s
router rejects Handler == nil and panics with “adding route without
handler function”.
- Add TestUnwrapResponseError: when the response is wrapped by a writer
that does not implement Unwrap() (e.g. &struct{ http.ResponseWriter }{}),
UnwrapResponse returns an error; the middleware must not panic and must
record http.response.status_code as 0 in the transaction.
## Documentation and examples
- README.md and example_test.go: switch imports and examples from
echo/v4 to echo/v5 and from echo.Context to *echo.Context.
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧Release
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
|
Hey @Scorfly, we can't really support this right now, since the module versioning needs to be consistent across packages, and we also want to support the three latest go versions. |
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.
BREAKING CHANGE: echo integration now requires github.com/labstack/echo/v5 and Go 1.25. Echo v4 is no longer supported.
Dependency and module
Echo v5 API adjustments
*echo.Contextinstead ofecho.Contextin handler and public API (GetHubFromContext, SetHubOnContext, GetSpanFromContext) to match v5’s pointer-based Context.func(c echo.Context) errortofunc(c *echo.Context) error.Context.Response()returnshttp.ResponseWriter, not*Response, soctx.Response().Statusis no longer available.HTTP status and Response handling
ctx.Response().Status withecho.UnwrapResponse(ctx.Response())to obtain*echo.Responseand useresp.StatuswhenUnwrapResponsesucceeds andresp.Status != 0.UnwrapResponsefails (e.g. middleware replaces the response with a writer that does not unwrap to*echo.Response), leave status at its zero value (0) instead of defaulting to 200.echo.HTTPStatusCoderinstead of*echo.HTTPErrorso that both*HTTPErrorand unexported*httpError(ErrNotFound, ErrMethodNotAllowed, etc.) are handled and the correct status is used for the transaction.Tests
router.GET("", nil). Echo v5’s router rejectsHandler == niland panics with “adding route without handler function”.TestUnwrapResponseError: when the response is wrapped by a writer that does not implementUnwrap()(e.g.&struct{ http.ResponseWriter }{}), UnwrapResponse returns an error; the middleware must not panic and must recordhttp.response.status_codeas 0 in the transaction.Documentation and examples
README.mdandexample_test.go: switch imports and examples from echo/v4 to echo/v5 and fromecho.Contextto*echo.Context.