feat(echo): add support for Echo v5 #1183
Open
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.