-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
Copy pathapplication.ex
75 lines (61 loc) · 1.92 KB
/
application.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
defmodule Sentry.Application do
@moduledoc false
use Application
alias Sentry.Config
@impl true
def start(_type, _opts) do
config = Config.validate!()
:ok = Config.persist(config)
http_client = Keyword.fetch!(config, :client)
maybe_http_client_spec =
if Code.ensure_loaded?(http_client) and function_exported?(http_client, :child_spec, 0) do
[http_client.child_spec()]
else
[]
end
integrations_config = Config.integrations()
children =
[
{Registry, keys: :unique, name: Sentry.Transport.SenderRegistry},
Sentry.Sources,
Sentry.Dedupe,
Sentry.ClientReport.Sender,
Sentry.OpenTelemetry.SpanStorage,
{Sentry.Integrations.CheckInIDMappings,
[
max_expected_check_in_time:
Keyword.fetch!(integrations_config, :max_expected_check_in_time)
]}
] ++
maybe_http_client_spec ++
[Sentry.Transport.SenderPool]
cache_loaded_applications()
with {:ok, pid} <-
Supervisor.start_link(children, strategy: :one_for_one, name: Sentry.Supervisor) do
start_integrations(integrations_config)
{:ok, pid}
end
end
defp cache_loaded_applications do
apps_with_vsns =
if Config.report_deps?() do
Map.new(Application.loaded_applications(), fn {app, _description, vsn} ->
{Atom.to_string(app), to_string(vsn)}
end)
else
%{}
end
:persistent_term.put({:sentry, :loaded_applications}, apps_with_vsns)
end
defp start_integrations(config) do
if config[:oban][:cron][:enabled] do
Sentry.Integrations.Oban.Cron.attach_telemetry_handler(config[:oban][:cron])
end
if config[:oban][:capture_errors] do
Sentry.Integrations.Oban.ErrorReporter.attach()
end
if config[:quantum][:cron][:enabled] do
Sentry.Integrations.Quantum.Cron.attach_telemetry_handler()
end
end
end