Skip to content

feat(middleware): RoundTripper chain; drop hackney_metrics#845

Merged
benoitc merged 2 commits intomasterfrom
feat/roundtripper-middleware
Apr 16, 2026
Merged

feat(middleware): RoundTripper chain; drop hackney_metrics#845
benoitc merged 2 commits intomasterfrom
feat/roundtripper-middleware

Conversation

@benoitc
Copy link
Copy Markdown
Owner

@benoitc benoitc commented Apr 16, 2026

Adds a fun-based middleware layer around hackney:request/1..5, like Go's http.RoundTripper. A chain [A, B, C] is outermost-first — A sees the request first and the response last — matching Plug, Rack and Tower. Configure per-request with {middleware, [Fun, ...]} or globally via application:set_env(hackney, middleware, [...]). Crashes propagate; send_request/2 stays transport-level and bypasses the chain.

The bundled metrics subsystem is gone: hackney_metrics, the backend behaviour, and the prometheus / dummy implementations, plus all the counter_inc/gauge_inc/histogram_observe calls scattered through hackney.erl, hackney_pool.erl, hackney_manager.erl and hackney_sup.erl. Metrics were always opinionated policy that did not belong in the client. guides/middleware.md documents the new API and ships worked prometheus and telemetry recipes so anyone upgrading can port in ~20 lines. Pool state remains observable through hackney_pool:get_stats/1.

817 tests pass (10 new middleware unit tests, 4 cowboy-based integration tests, the 10 metrics tests removed).

benoitc added 2 commits April 16, 2026 02:54
Fun-based middleware around hackney:request/1..5, outermost-first,
per-request or app-env. send_request/2 bypasses. Metrics subsystem
removed; guides/middleware.md shows prometheus/telemetry recipes.
@benoitc benoitc merged commit dae2279 into master Apr 16, 2026
5 checks passed
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.

1 participant