sergiotapia / magnetissimo

Web application that indexes all popular torrent sites, and saves it to the local database.
MIT License
2.99k stars 187 forks source link

Enable Sentry.io integration #107

Closed tchoutri closed 6 years ago

tchoutri commented 6 years ago

Sentry provides a free plan for individuals. I intend to use it so I can leave Magnetissimo running on a box and get all the exceptions reported to one place. From time to time we're getting some type-related errors (like, :ok or nil as argument for functions) and before having the whole codebase checked by Dialyzer I think it's a good step to make.

sergiotapia commented 6 years ago

@tchoutri Would this work fine for someone who doesn't want to configure Sentry? How does the Sentry package handle being set up without any of the configs being set in dev.secret?

tchoutri commented 6 years ago

I still need to test deeper. I already tried starting the app with the configuration block commented out and it started without trouble. I'll provoke some exceptions when I have access to my computer so I can be sure that it won't break everything to have sentry deactivated. Théophile Choutri

https://www.linkedin.com/in/tchoutri

tchoutri commented 6 years ago

So apparently if I put a raise(ArgumentError) in the middle of a crawler, with the configuration block commented out, this happens:

[error] GenServer Magnetissimo.Crawler.NyaaSi terminating
** (ArgumentError) argument error
    (magnetissimo) lib/magnetissimo/crawler/nyaasi.ex:74: Magnetissimo.Crawler.NyaaSi.process/2
    (magnetissimo) lib/magnetissimo/crawler/nyaasi.ex:61: Magnetissimo.Crawler.NyaaSi.handle_info/2
    (stdlib) gen_server.erl:616: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:686: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: :work
State: {[page_link: "https://nyaa.si/rss?c=6_0&m", page_link: "https://nyaa.si/rss?c=5_0&m"], [page_link: "https://nyaa.si/rss?c=1_0&m", page_link: "https://nyaa.si/rss?c=2_0&m", page_link: "https://nyaa.si/rss?c=
3_0&m", page_link: "https://nyaa.si/rss?c=4_0&m"]}
[warn] Unable to notify Sentry due to %FunctionClauseError{args: nil, arity: 1, clauses: nil, function: :parse, kind: nil, module: URI}! [initial_call: {Magnetissimo.Crawler.NyaaSi, :init, [:Argument__1]}, pid: #P
ID<0.929.0>, registered_name: Magnetissimo.Crawler.NyaaSi, error_info: {:error, %ArgumentError{message: "argument error"}, [{Magnetissimo.Crawler.NyaaSi, :process, 2, [file: 'lib/magnetissimo/crawler/nyaasi.ex', l
ine: 74]}, {Magnetissimo.Crawler.NyaaSi, :handle_info, 2, [file: 'lib/magnetissimo/crawler/nyaasi.ex', line: 61]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 616]}, {:gen_server, :handle_msg, 6
, [file: 'gen_server.erl', line: 686]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}, ancestors: [Magnetissimo.Crawler.Supervisor, Magnetissimo.Supervisor, #PID<0.747.0>], message_queue_le
n: 0, messages: [], links: [#PID<0.921.0>], dictionary: [rand_seed: {%{bits: 58, jump: #Function<8.15449617/1 in :rand.mk_alg/1>, next: #Function<5.15449617/1 in :rand.mk_alg/1>, type: :exrop, uniform: #Function<6
.15449617/1 in :rand.mk_alg/1>, uniform_n: #Function<7.15449617/2 in :rand.mk_alg/1>, weak_low_bits: 1}, [218757090673262177 | 268509756974521188]}], trap_exit: false, status: :running, heap_size: 987, stack_size:
 27, reductions: 548]

Which means that for us it doesn't change anything, and since it's a :dev-only dependency, the end-user doesn't have to care about that.