Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellhenke committed Sep 5, 2018
1 parent fe158df commit f2efbff
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 547 deletions.
4 changes: 0 additions & 4 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@
{Credo.Check.Warning.BoolOperationOnSameValues},
{Credo.Check.Warning.IExPry},
{Credo.Check.Warning.IoInspect},
{Credo.Check.Warning.NameRedeclarationByAssignment},
{Credo.Check.Warning.NameRedeclarationByCase},
{Credo.Check.Warning.NameRedeclarationByDef},
{Credo.Check.Warning.NameRedeclarationByFn},
{Credo.Check.Warning.OperationOnSameValues},
{Credo.Check.Warning.OperationWithConstantResult},
{Credo.Check.Warning.UnusedEnumOperation},
Expand Down
22 changes: 5 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
language: elixir
elixir:
- 1.3.4
- 1.4
- 1.5
- 1.6
- 1.7
otp_release:
- 18.3
- 19.3
- 20.2
- 21.0
env:
- STRICT=true
- STRICT=false
matrix:
exclude:
- elixir: 1.6
env: STRICT=false
- elixir: 1.3.4
env: STRICT=true
- elixir: 1.4
- otp_release: 20.2
env: STRICT=true
- elixir: 1.5
env: STRICT=true
- elixir: 1.6
otp_release: 18.3
- elixir: 1.3.4
otp_release: 20.2
- otp_release: 21.0
env: STRICT=false
notifications:
email:
- mitch@rokkincat.com
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ try do
ThisWillError.reall()
rescue
my_exception ->
Sentry.capture_exception(my_exception, [stacktrace: System.stacktrace(), extra: %{extra: information}])
Sentry.capture_exception(my_exception, [stacktrace: __STACKTRACE__, extra: %{extra: information}])
end
```

Expand Down
3 changes: 3 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ config :sentry,
included_environments: [:test],
client: Sentry.TestClient,
hackney_opts: [recv_timeout: 50]

config :ex_unit,
assert_receive_timeout: 500
74 changes: 74 additions & 0 deletions lib/sentry/logger_backend.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
defmodule Sentry.LoggerBackend do
@moduledoc """
This module makes use of Elixir 1.7's new Logger metadata to report
crashes processes. It replaces the previous `Sentry.Logger` sytem.
"""
@behaviour :gen_event

defstruct level: nil

def init(__MODULE__) do
config = Application.get_env(:logger, :sentry, [])
{:ok, init(config, %__MODULE__{})}
end

def init({__MODULE__, opts}) when is_list(opts) do
config =
Application.get_env(:logger, :sentry, [])
|> Keyword.merge(opts)

{:ok, init(config, %__MODULE__{})}
end

def handle_call({:configure, _options}, state) do
{:ok, :ok, state}
end

def handle_event({_level, gl, {Logger, _, _, _}}, state) when node(gl) != node() do
{:ok, state}
end

def handle_event({_level, _gl, {Logger, _msg, _ts, meta}}, state) do
case Keyword.get(meta, :crash_reason) do
{reason, stacktrace} ->
opts =
Keyword.put([], :event_source, :logger)
|> Keyword.put(:stacktrace, stacktrace)

Sentry.capture_exception(reason, opts)

reason when is_atom(reason) ->
Sentry.capture_exception(reason, event_source: :logger)

_ ->
:ok
end

{:ok, state}
end

def handle_event(:flush, state) do
{:ok, state}
end

def handle_event(_, state) do
{:ok, state}
end

def handle_info(_, state) do
{:ok, state}
end

def code_change(_old_vsn, state, _extra) do
{:ok, state}
end

def terminate(_reason, _state) do
:ok
end

defp init(config, %__MODULE__{} = state) do
level = Keyword.get(config, :level)
%{state | level: level}
end
end
2 changes: 1 addition & 1 deletion lib/sentry/phoenix_endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Sentry.Phoenix.Endpoint do
super(conn, opts)
catch
kind, reason ->
stacktrace = System.stacktrace()
stacktrace = __STACKTRACE__
request = Sentry.Plug.build_request_interface_data(conn, [])
exception = Exception.normalize(kind, reason, stacktrace)

Expand Down
3 changes: 3 additions & 0 deletions lib/sentry/plug.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
if Code.ensure_loaded?(Plug) do
require Protocol
Protocol.derive(Jason.Encoder, Plug.Upload)

defmodule Sentry.Plug do
@default_scrubbed_param_keys ["password", "passwd", "secret"]
@default_scrubbed_header_keys ["authorization", "authentication", "cookie"]
Expand Down
8 changes: 4 additions & 4 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule Sentry.Mixfile do
def project do
[
app: :sentry,
version: "6.4.2",
elixir: "~> 1.3",
version: "6.4.1",
elixir: "~> 1.7",
description: "The Official Elixir client for Sentry",
package: package(),
deps: deps(),
Expand All @@ -29,8 +29,8 @@ defmodule Sentry.Mixfile do
{:plug, "~> 1.6", optional: true},
{:phoenix, "~> 1.3", optional: true},
{:dialyxir, "> 0.0.0", only: [:dev], runtime: false},
{:ex_doc, "~> 0.18.0", only: :dev},
{:credo, "~> 0.9.0", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.19.0", only: :dev},
{:credo, "~> 0.10.0", only: [:dev, :test], runtime: false},
{:bypass, "~> 0.8.0", only: [:test]}
]
end
Expand Down
8 changes: 6 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
"certifi": {:hex, :certifi, "2.3.1", "d0f424232390bf47d82da8478022301c561cf6445b5b5fb6a84d49a9e76d2639", [:rebar3], [{:parse_trans, "3.2.0", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm"},
"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"},
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"},
"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"},
"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"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.18.4", "4406b8891cecf1352f49975c6d554e62e4341ceb41b9338949077b0d4a97b949", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"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"},
"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"},
"idna": {:hex, :idna, "5.1.2", "e21cb58a09f0228a9e0b95eaa1217f1bcfc31a1aaa6e1fdf2f53a33f7dbd9494", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"makeup": {:hex, :makeup, "0.5.1", "966c5c2296da272d42f1de178c1d135e432662eca795d6dc12e5e8787514edf7", [:mix], [{:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"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"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
"mime": {:hex, :mime, "1.3.0", "5e8d45a39e95c650900d03f897fbf99ae04f60ab1daa4a34c7a20a5151b7a5fe", [:mix], [], "hexpm"},
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.2.2", "d526b23bdceb04c7ad15b33c57c4526bf5f50aaa70c7c141b4b4624555c68259", [:mix], [], "hexpm"},
"parse_trans": {:hex, :parse_trans, "3.2.0", "2adfa4daf80c14dc36f522cf190eb5c4ee3e28008fc6394397c16f62a26258c2", [:rebar3], [], "hexpm"},
"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"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], [], "hexpm"},
Expand Down
2 changes: 1 addition & 1 deletion test/client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ defmodule Sentry.ClientTest do
{:ok, _} =
Sentry.capture_exception(
e,
stacktrace: System.stacktrace(),
stacktrace: __STACKTRACE__,
result: :sync,
sample_rate: 1
)
Expand Down
Loading

0 comments on commit f2efbff

Please sign in to comment.