Skip to content

Commit 906e670

Browse files
authored
Merge pull request #1052 from appsignal/bump-httpoison-3
Allow HTTPoison 3.0 as optional dependency
2 parents 0bbb64a + 83dba66 commit 906e670

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

.changesets/allow-httpoison-3.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
bump: patch
3+
type: change
4+
integrations: all
5+
---
6+
7+
Allow HTTPoison 3.0 to be used as an optional dependency. Applications
8+
on HTTPoison 3.0 can now use AppSignal's HTTPoison instrumentation
9+
without a version conflict.

.dialyzer_ignore.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# HTTPoison 3.0's `HTTPoison.Base` macro generates a `stream_next/1` that calls
2+
# `:hackney.stream_next/1`. hackney 4.0 narrowed that function's typespec, so
3+
# dialyzer treats the error clause as dead code and flags the generated spec and
4+
# callback. The code is HTTPoison's, injected into `Appsignal.HTTPoison` through
5+
# `use`, so we ignore these rather than work around a third-party type change.
6+
[
7+
{"deps/httpoison/lib/httpoison/base.ex", :callback_arg_type_mismatch},
8+
{"deps/httpoison/lib/httpoison/base.ex", :callback_type_mismatch},
9+
{"deps/httpoison/lib/httpoison/base.ex", :pattern_match_cov},
10+
{"lib/appsignal/httpoison.ex", :invalid_contract}
11+
]

mix.exs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ defmodule Appsignal.Mixfile do
5454
],
5555
dialyzer: [
5656
plt_file: {:no_warn, "priv/plts/dialyzer.plt"},
57-
plt_add_apps: [:mix]
57+
plt_add_apps: [:mix],
58+
ignore_warnings: ".dialyzer_ignore.exs"
5859
]
5960
]
6061
end
@@ -135,6 +136,14 @@ defmodule Appsignal.Mixfile do
135136
false -> "~> 0.4 or ~> 1.0"
136137
end
137138

139+
# httpoison 3.0 depends on hackney 4.0, which pulls in quic and requires
140+
# OTP 26 or later. Cap httpoison at 2.x on older OTP releases.
141+
httpoison_version =
142+
case otp_version < "26" do
143+
true -> "~> 2.0"
144+
false -> "~> 2.0 or ~> 3.0"
145+
end
146+
138147
mime_dependency =
139148
case Version.compare(system_version, "1.10.0") do
140149
:lt -> [{:mime, "~> 1.0", only: [:test, :test_no_nif]}]
@@ -195,7 +204,7 @@ defmodule Appsignal.Mixfile do
195204
{:credo, credo_version, only: [:test, :dev], runtime: false},
196205
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
197206
{:telemetry, telemetry_version},
198-
{:httpoison, "~> 2.0", optional: true}
207+
{:httpoison, httpoison_version, optional: true}
199208
] ++ mime_dependency ++ logger_backends_dependency ++ hpax_dependency
200209
end
201210
end

0 commit comments

Comments
 (0)