Skip to content

Commit f2efbff

Browse files
committed
testing
1 parent fe158df commit f2efbff

File tree

13 files changed

+318
-547
lines changed

13 files changed

+318
-547
lines changed

.credo.exs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@
106106
{Credo.Check.Warning.BoolOperationOnSameValues},
107107
{Credo.Check.Warning.IExPry},
108108
{Credo.Check.Warning.IoInspect},
109-
{Credo.Check.Warning.NameRedeclarationByAssignment},
110-
{Credo.Check.Warning.NameRedeclarationByCase},
111-
{Credo.Check.Warning.NameRedeclarationByDef},
112-
{Credo.Check.Warning.NameRedeclarationByFn},
113109
{Credo.Check.Warning.OperationOnSameValues},
114110
{Credo.Check.Warning.OperationWithConstantResult},
115111
{Credo.Check.Warning.UnusedEnumOperation},

.travis.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
language: elixir
22
elixir:
3-
- 1.3.4
4-
- 1.4
5-
- 1.5
6-
- 1.6
3+
- 1.7
74
otp_release:
8-
- 18.3
9-
- 19.3
105
- 20.2
6+
- 21.0
117
env:
128
- STRICT=true
139
- STRICT=false
1410
matrix:
1511
exclude:
16-
- elixir: 1.6
17-
env: STRICT=false
18-
- elixir: 1.3.4
19-
env: STRICT=true
20-
- elixir: 1.4
12+
- otp_release: 20.2
2113
env: STRICT=true
22-
- elixir: 1.5
23-
env: STRICT=true
24-
- elixir: 1.6
25-
otp_release: 18.3
26-
- elixir: 1.3.4
27-
otp_release: 20.2
14+
- otp_release: 21.0
15+
env: STRICT=false
2816
notifications:
2917
email:
3018

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ try do
6969
ThisWillError.reall()
7070
rescue
7171
my_exception ->
72-
Sentry.capture_exception(my_exception, [stacktrace: System.stacktrace(), extra: %{extra: information}])
72+
Sentry.capture_exception(my_exception, [stacktrace: __STACKTRACE__, extra: %{extra: information}])
7373
end
7474
```
7575

config/test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ config :sentry,
55
included_environments: [:test],
66
client: Sentry.TestClient,
77
hackney_opts: [recv_timeout: 50]
8+
9+
config :ex_unit,
10+
assert_receive_timeout: 500

lib/sentry/logger_backend.ex

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
defmodule Sentry.LoggerBackend do
2+
@moduledoc """
3+
This module makes use of Elixir 1.7's new Logger metadata to report
4+
crashes processes. It replaces the previous `Sentry.Logger` sytem.
5+
"""
6+
@behaviour :gen_event
7+
8+
defstruct level: nil
9+
10+
def init(__MODULE__) do
11+
config = Application.get_env(:logger, :sentry, [])
12+
{:ok, init(config, %__MODULE__{})}
13+
end
14+
15+
def init({__MODULE__, opts}) when is_list(opts) do
16+
config =
17+
Application.get_env(:logger, :sentry, [])
18+
|> Keyword.merge(opts)
19+
20+
{:ok, init(config, %__MODULE__{})}
21+
end
22+
23+
def handle_call({:configure, _options}, state) do
24+
{:ok, :ok, state}
25+
end
26+
27+
def handle_event({_level, gl, {Logger, _, _, _}}, state) when node(gl) != node() do
28+
{:ok, state}
29+
end
30+
31+
def handle_event({_level, _gl, {Logger, _msg, _ts, meta}}, state) do
32+
case Keyword.get(meta, :crash_reason) do
33+
{reason, stacktrace} ->
34+
opts =
35+
Keyword.put([], :event_source, :logger)
36+
|> Keyword.put(:stacktrace, stacktrace)
37+
38+
Sentry.capture_exception(reason, opts)
39+
40+
reason when is_atom(reason) ->
41+
Sentry.capture_exception(reason, event_source: :logger)
42+
43+
_ ->
44+
:ok
45+
end
46+
47+
{:ok, state}
48+
end
49+
50+
def handle_event(:flush, state) do
51+
{:ok, state}
52+
end
53+
54+
def handle_event(_, state) do
55+
{:ok, state}
56+
end
57+
58+
def handle_info(_, state) do
59+
{:ok, state}
60+
end
61+
62+
def code_change(_old_vsn, state, _extra) do
63+
{:ok, state}
64+
end
65+
66+
def terminate(_reason, _state) do
67+
:ok
68+
end
69+
70+
defp init(config, %__MODULE__{} = state) do
71+
level = Keyword.get(config, :level)
72+
%{state | level: level}
73+
end
74+
end

lib/sentry/phoenix_endpoint.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule Sentry.Phoenix.Endpoint do
2929
super(conn, opts)
3030
catch
3131
kind, reason ->
32-
stacktrace = System.stacktrace()
32+
stacktrace = __STACKTRACE__
3333
request = Sentry.Plug.build_request_interface_data(conn, [])
3434
exception = Exception.normalize(kind, reason, stacktrace)
3535

lib/sentry/plug.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
if Code.ensure_loaded?(Plug) do
2+
require Protocol
3+
Protocol.derive(Jason.Encoder, Plug.Upload)
4+
25
defmodule Sentry.Plug do
36
@default_scrubbed_param_keys ["password", "passwd", "secret"]
47
@default_scrubbed_header_keys ["authorization", "authentication", "cookie"]

mix.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ defmodule Sentry.Mixfile do
44
def project do
55
[
66
app: :sentry,
7-
version: "6.4.2",
8-
elixir: "~> 1.3",
7+
version: "6.4.1",
8+
elixir: "~> 1.7",
99
description: "The Official Elixir client for Sentry",
1010
package: package(),
1111
deps: deps(),
@@ -29,8 +29,8 @@ defmodule Sentry.Mixfile do
2929
{:plug, "~> 1.6", optional: true},
3030
{:phoenix, "~> 1.3", optional: true},
3131
{:dialyxir, "> 0.0.0", only: [:dev], runtime: false},
32-
{:ex_doc, "~> 0.18.0", only: :dev},
33-
{:credo, "~> 0.9.0", only: [:dev, :test], runtime: false},
32+
{:ex_doc, "~> 0.19.0", only: :dev},
33+
{:credo, "~> 0.10.0", only: [:dev, :test], runtime: false},
3434
{:bypass, "~> 0.8.0", only: [:test]}
3535
]
3636
end

mix.lock

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
"certifi": {:hex, :certifi, "2.3.1", "d0f424232390bf47d82da8478022301c561cf6445b5b5fb6a84d49a9e76d2639", [:rebar3], [{:parse_trans, "3.2.0", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
55
"cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"},
66
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"},
7-
"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"},
7+
"credo": {:hex, :credo, "0.10.0", "66234a95effaf9067edb19fc5d0cd5c6b461ad841baac42467afed96c78e5e9e", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
88
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
99
"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"},
10+
"ex_doc": {:hex, :ex_doc, "0.19.0", "e22b6434373b4870ea77b24df069dbac7002c1f483615e9ebfc0c37497e1c75c", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
1111
"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"},
1212
"idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
13+
"jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
14+
"makeup": {:hex, :makeup, "0.5.1", "966c5c2296da272d42f1de178c1d135e432662eca795d6dc12e5e8787514edf7", [:mix], [{:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
15+
"makeup_elixir": {:hex, :makeup_elixir, "0.8.0", "1204a2f5b4f181775a0e456154830524cf2207cf4f9112215c05e0b76e4eca8b", [:mix], [{:makeup, "~> 0.5.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
1316
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
1417
"mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [:mix], [], "hexpm"},
1518
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
19+
"nimble_parsec": {:hex, :nimble_parsec, "0.2.2", "d526b23bdceb04c7ad15b33c57c4526bf5f50aaa70c7c141b4b4624555c68259", [:mix], [], "hexpm"},
1620
"parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"},
1721
"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"},
1822
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], [], "hexpm"},

test/client_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ defmodule Sentry.ClientTest do
244244
{:ok, _} =
245245
Sentry.capture_exception(
246246
e,
247-
stacktrace: System.stacktrace(),
247+
stacktrace: __STACKTRACE__,
248248
result: :sync,
249249
sample_rate: 1
250250
)

0 commit comments

Comments
 (0)