Skip to content

Commit 707fe48

Browse files
Merge pull request #301 from getsentry/fix-deps
Bring back report_deps
2 parents b061eb3 + 2a1528a commit 707fe48

File tree

8 files changed

+42
-41
lines changed

8 files changed

+42
-41
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ For optional settings check the [docs](https://hexdocs.pm/sentry/readme.html).
102102
| `after_send_event` | False | | |
103103
| `sample_rate` | False | 1.0 | |
104104
| `in_app_module_whitelist` | False | `[]` | |
105-
| `report_deps` | False | False | Will attempt to load Mix dependencies at compile time to report alongside events. This was switched to default to false following a bug in the parallel compiler ([#232](https://github.com/getsentry/sentry-elixir/issues/232) / [elixir-lang/elixir#7699](https://github.com/elixir-lang/elixir/issues/7699)) |
105+
| `report_deps` | False | True | Will attempt to load Mix dependencies at compile time to report alongside events |
106106
| `enable_source_code_context` | False | False | |
107107
| `root_source_code_path` | Required if `enable_source_code_context` is enabled | | Should generally be set to `File.cwd!`|
108108
| `context_lines` | False | 3 | |

config/test.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ config :sentry,
44
environment_name: :test,
55
included_environments: [:test],
66
client: Sentry.TestClient,
7-
hackney_opts: [recv_timeout: 50],
8-
report_deps: true
7+
hackney_opts: [recv_timeout: 50]

lib/sentry/config.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ defmodule Sentry.Config do
120120
end
121121

122122
def report_deps do
123-
get_config(:report_deps, default: false, check_dsn: false)
123+
get_config(:report_deps, default: true, check_dsn: false)
124124
end
125125

126126
defp get_config(key, opts \\ []) when is_atom(key) do

lib/sentry/event.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ defmodule Sentry.Event do
4141
@enable_deps_reporting Config.report_deps()
4242
@deps if(
4343
@enable_deps_reporting,
44-
do: Util.mix_deps_to_map(Mix.Dep.loaded(env: Mix.env())),
44+
do: Util.mix_deps(),
4545
else: %{}
4646
)
4747

lib/sentry/util.ex

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,15 @@ defmodule Sentry.Util do
2525
|> String.trim_trailing("Z")
2626
end
2727

28-
@spec mix_deps_to_map([Mix.Dep.t()]) :: map()
29-
def mix_deps_to_map([%Mix.Dep{} | _rest] = modules) do
30-
Enum.reduce(modules, %{}, fn x, acc ->
31-
case x.status do
32-
{:ok, version} -> Map.put(acc, x.app, version)
33-
_ -> acc
34-
end
28+
@spec mix_deps() :: map()
29+
def mix_deps() do
30+
Mix.Project.deps_paths()
31+
|> Map.keys()
32+
|> Enum.reduce(%{}, fn app, acc ->
33+
Map.put(acc, app, Application.spec(app, :vsn))
3534
end)
3635
end
3736

38-
def mix_deps_to_map(modules), do: modules
39-
4037
@doc """
4138
Per http://www.ietf.org/rfc/rfc4122.txt
4239
"""

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule Sentry.Mixfile do
3030
{:phoenix, "~> 1.3", optional: true},
3131
{:dialyxir, "> 0.0.0", only: [:dev], runtime: false},
3232
{:ex_doc, "~> 0.18.0", only: :dev},
33-
{:credo, "~> 0.8", only: [:dev, :test], runtime: false},
33+
{:credo, "~> 0.9.0", only: [:dev, :test], runtime: false},
3434
{:bypass, "~> 0.8.0", only: [:test]}
3535
]
3636
end

mix.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"},
77
"credo": {:hex, :credo, "0.9.3", "76fa3e9e497ab282e0cf64b98a624aa11da702854c52c82db1bf24e54ab7c97a", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
88
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
9-
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
10-
"ex_doc": {:hex, :ex_doc, "0.18.3", "f4b0e4a2ec6f333dccf761838a4b253d75e11f714b85ae271c9ae361367897b7", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
11-
"hackney": {:hex, :hackney, "1.12.1", "8bf2d0e11e722e533903fe126e14d6e7e94d9b7983ced595b75f532e04b7fdc7", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.1", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
12-
"idna": {:hex, :idna, "5.1.1", "cbc3b2fa1645113267cc59c760bafa64b2ea0334635ef06dbac8801e42f7279c", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
9+
"earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"},
10+
"ex_doc": {:hex, :ex_doc, "0.18.4", "4406b8891cecf1352f49975c6d554e62e4341ceb41b9338949077b0d4a97b949", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
11+
"hackney": {:hex, :hackney, "1.13.0", "24edc8cd2b28e1c652593833862435c80661834f6c9344e84b6a2255e7aeef03", [:rebar3], [{:certifi, "2.3.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.2", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
12+
"idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
1313
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
1414
"mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [:mix], [], "hexpm"},
1515
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
1616
"parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"},
1717
"phoenix": {:hex, :phoenix, "1.3.3", "bafb5fa408d202e8d9f739e781bdb908446a2c1c1e00797c1158918ed55566a4", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
1818
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], [], "hexpm"},
19-
"plug": {:hex, :plug, "1.6.0", "90d338a44c8cd762c32d3ea324f6728445c6145b51895403854b77f1536f1617", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
19+
"plug": {:hex, :plug, "1.6.1", "c62fe7623d035020cf989820b38490460e6903ab7eee29e234b7586e9b6c91d6", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
2020
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
2121
"ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm"},
2222
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},

test/event_test.exs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -447,26 +447,31 @@ defmodule Sentry.EventTest do
447447
exception = RuntimeError.exception("error")
448448
event = Sentry.Event.transform_exception(exception, [])
449449

450-
assert event.modules == %{
451-
phoenix: "1.3.3",
452-
phoenix_pubsub: "1.0.2",
453-
bunt: "0.2.0",
454-
bypass: "0.8.1",
455-
certifi: "2.3.1",
456-
cowboy: "1.1.2",
457-
cowlib: "1.0.2",
458-
credo: "0.9.3",
459-
hackney: "1.12.1",
460-
idna: "5.1.1",
461-
metrics: "1.0.1",
462-
mime: "1.3.0",
463-
mimerl: "1.0.2",
464-
parse_trans: "3.2.0",
465-
plug: "1.6.0",
466-
poison: "3.1.0",
467-
ranch: "1.3.2",
468-
ssl_verify_fun: "1.1.1",
469-
unicode_util_compat: "0.3.1"
470-
}
450+
modules =
451+
event.modules
452+
|> Map.keys()
453+
|> Enum.sort()
454+
455+
assert modules == [
456+
:bunt,
457+
:bypass,
458+
:certifi,
459+
:cowboy,
460+
:cowlib,
461+
:credo,
462+
:hackney,
463+
:idna,
464+
:metrics,
465+
:mime,
466+
:mimerl,
467+
:parse_trans,
468+
:phoenix,
469+
:phoenix_pubsub,
470+
:plug,
471+
:poison,
472+
:ranch,
473+
:ssl_verify_fun,
474+
:unicode_util_compat
475+
]
471476
end
472477
end

0 commit comments

Comments
 (0)