Skip to content

Commit fbbf707

Browse files
solnicwhatyouhide
andauthored
Add :in_app_otp_apps option (#854)
Co-authored-by: Andrea Leopardi <[email protected]>
1 parent b72e78a commit fbbf707

File tree

25 files changed

+355
-0
lines changed

25 files changed

+355
-0
lines changed

lib/sentry/application.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ defmodule Sentry.Application do
1010
config = Config.validate!()
1111
:ok = Config.persist(config)
1212

13+
Config.put_config(
14+
:in_app_module_allow_list,
15+
Config.in_app_module_allow_list() ++ resolve_in_app_module_allow_list()
16+
)
17+
1318
http_client = Keyword.fetch!(config, :client)
1419

1520
maybe_http_client_spec =
@@ -71,4 +76,13 @@ defmodule Sentry.Application do
7176
Sentry.Integrations.Quantum.Cron.attach_telemetry_handler()
7277
end
7378
end
79+
80+
defp resolve_in_app_module_allow_list do
81+
Enum.flat_map(Config.in_app_otp_apps(), fn app ->
82+
case :application.get_key(app, :modules) do
83+
{:ok, modules} -> modules
84+
_ -> []
85+
end
86+
end)
87+
end
7488
end

lib/sentry/config.ex

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,20 @@ defmodule Sentry.Config do
388388
The number of lines of source code
389389
before and after the line that caused the exception to report.
390390
"""
391+
],
392+
in_app_otp_apps: [
393+
type: {:list, :atom},
394+
default: [],
395+
type_doc: "list of `t:atom/0`",
396+
doc: """
397+
A list of OTP application names that will be used to populate additional modules for the
398+
`:in_app_module_allow_list` option. List your application (or the applications in your
399+
umbrella project) for them to show as "in-app" in stacktraces in Sentry. We recommend using
400+
this option over `:in_app_module_allow_list`, unless you need more control over the exact
401+
modules to consider as "in-app".
402+
403+
*Available since v10.9.0*.
404+
"""
391405
]
392406
]
393407

@@ -575,6 +589,9 @@ defmodule Sentry.Config do
575589
@spec report_deps?() :: boolean()
576590
def report_deps?, do: fetch!(:report_deps)
577591

592+
@spec in_app_otp_apps() :: [atom()]
593+
def in_app_otp_apps, do: fetch!(:in_app_otp_apps)
594+
578595
@spec json_library() :: module()
579596
def json_library, do: fetch!(:json_library)
580597

mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ defmodule Sentry.Mixfile do
136136

137137
defp run_integration_tests_if_supported(args) do
138138
if Version.match?(System.version(), ">= 1.16.0") do
139+
run_integration_tests("umbrella", args)
139140
run_integration_tests("phoenix_app", args)
140141
else
141142
Mix.shell().info("Skipping integration tests for Elixir versions < 1.16")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["mix.exs", "config/*.exs"],
4+
subdirectories: ["apps/*"]
5+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# If the VM crashes, it generates a dump, let's ignore it too.
14+
erl_crash.dump
15+
16+
# Also ignore archive artifacts (built via "mix archive.build").
17+
*.ez
18+
19+
# Temporary files, for example, from tests.
20+
/tmp/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# PhoenixAppUmbrella
2+
3+
**TODO: Add description**
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# If the VM crashes, it generates a dump, let's ignore it too.
14+
erl_crash.dump
15+
16+
# Also ignore archive artifacts (built via "mix archive.build").
17+
*.ez
18+
19+
# Ignore package tarball (built via "mix hex.build").
20+
admin-*.tar
21+
22+
# Temporary files, for example, from tests.
23+
/tmp/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Admin
2+
3+
**TODO: Add description**
4+
5+
## Installation
6+
7+
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
8+
by adding `admin` to your list of dependencies in `mix.exs`:
9+
10+
```elixir
11+
def deps do
12+
[
13+
{:admin, "~> 0.1.0"}
14+
]
15+
end
16+
```
17+
18+
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
19+
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
20+
be found at <https://hexdocs.pm/admin>.
21+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
defmodule Admin do
2+
@moduledoc """
3+
Documentation for `Admin`.
4+
"""
5+
6+
@doc """
7+
Hello world.
8+
9+
## Examples
10+
11+
iex> Admin.hello()
12+
:world
13+
14+
"""
15+
def hello do
16+
:world
17+
end
18+
end

0 commit comments

Comments
 (0)