Skip to content

Commit 92cd150

Browse files
committed
put args in stacktrace frames
1 parent 1900e9f commit 92cd150

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

lib/sentry/event.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ defmodule Sentry.Event do
8989
server_name = Config.server_name()
9090

9191
env = Config.environment_name()
92-
f_args = args_from_stacktrace(stacktrace)
9392

9493
%Event{
9594
culprit: culprit_from_stacktrace(stacktrace),
@@ -101,7 +100,6 @@ defmodule Sentry.Event do
101100
exception: exception,
102101
stacktrace: %{
103102
frames: stacktrace_to_frames(stacktrace),
104-
vars: f_args,
105103
},
106104
release: release,
107105
extra: extra,
@@ -173,6 +171,7 @@ defmodule Sentry.Event do
173171
stacktrace
174172
|> Enum.map(fn(line) ->
175173
{mod, function, arity_or_args, location} = line
174+
f_args = args_from_stacktrace([line])
176175
arity = arity_to_integer(arity_or_args)
177176
file = Keyword.get(location, :file)
178177
file = if(file, do: String.Chars.to_string(file), else: file)
@@ -184,6 +183,7 @@ defmodule Sentry.Event do
184183
module: mod,
185184
lineno: line_number,
186185
in_app: is_in_app?(mod, in_app_module_whitelist),
186+
vars: f_args,
187187
}
188188
|> put_source_context(file, line_number)
189189
end)

test/event_test.exs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ defmodule Sentry.EventTest do
2525
assert event.level == "error"
2626
assert event.message == "(UndefinedFunctionError) function Sentry.Event.not_a_function/3 is undefined or private"
2727
assert is_binary(event.server_name)
28-
assert event.stacktrace == %{vars: %{"arg0" => "1", "arg1" => "2", "arg2" => "3"},
28+
assert event.stacktrace == %{
2929
frames: Enum.reverse([
30-
%{filename: nil, function: "Sentry.Event.not_a_function/3", lineno: nil, module: Sentry.Event, context_line: nil, post_context: [], pre_context: [], in_app: false},
31-
%{filename: "test/event_test.exs", function: "Sentry.EventTest.event_generated_by_exception/1", lineno: 8, module: Sentry.EventTest, context_line: nil, post_context: [], pre_context: [], in_app: false},
32-
%{filename: "test/event_test.exs", function: "Sentry.EventTest.\"test parses error exception\"/1", lineno: 15, module: Sentry.EventTest, context_line: nil, post_context: [], pre_context: [], in_app: false},
33-
%{filename: "lib/ex_unit/runner.ex", function: "ExUnit.Runner.exec_test/1", lineno: 302, module: ExUnit.Runner, context_line: nil, post_context: [], pre_context: [], in_app: false},
34-
%{filename: "timer.erl", function: ":timer.tc/1", lineno: 166, module: :timer, context_line: nil, post_context: [], pre_context: [], in_app: false},
35-
%{filename: "lib/ex_unit/runner.ex", function: "anonymous fn/3 in ExUnit.Runner.spawn_test/3", lineno: 250, module: ExUnit.Runner, context_line: nil, post_context: [], pre_context: [], in_app: false}])
30+
%{filename: nil, function: "Sentry.Event.not_a_function/3", lineno: nil, module: Sentry.Event, context_line: nil, post_context: [], pre_context: [], in_app: false, vars: %{"arg0" => "1", "arg1" => "2", "arg2" => "3"}},
31+
%{filename: "test/event_test.exs", function: "Sentry.EventTest.event_generated_by_exception/1", lineno: 8, module: Sentry.EventTest, context_line: nil, post_context: [], pre_context: [], in_app: false, vars: %{}},
32+
%{filename: "test/event_test.exs", function: "Sentry.EventTest.\"test parses error exception\"/1", lineno: 15, module: Sentry.EventTest, context_line: nil, post_context: [], pre_context: [], in_app: false, vars: %{}},
33+
%{filename: "lib/ex_unit/runner.ex", function: "ExUnit.Runner.exec_test/1", lineno: 302, module: ExUnit.Runner, context_line: nil, post_context: [], pre_context: [], in_app: false, vars: %{}},
34+
%{filename: "timer.erl", function: ":timer.tc/1", lineno: 166, module: :timer, context_line: nil, post_context: [], pre_context: [], in_app: false, vars: %{}},
35+
%{filename: "lib/ex_unit/runner.ex", function: "anonymous fn/3 in ExUnit.Runner.spawn_test/3", lineno: 250, module: ExUnit.Runner, context_line: nil, post_context: [], pre_context: [], in_app: false, vars: %{}}])
3636
}
3737
assert event.tags == %{}
3838
assert event.timestamp =~ ~r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
@@ -85,35 +85,38 @@ defmodule Sentry.EventTest do
8585
{:other_module, :a_method, 8, []}, {:random, :uniform, 0, []},
8686
{Sentry.Submodule.Fun, :this_method, 0, []}]])
8787
assert %{
88-
vars: %{},
8988
frames: [
9089
%{
9190
module: Sentry.Submodule.Fun,
9291
function: "Sentry.Submodule.Fun.this_method/0",
9392
in_app: true,
9493
filename: nil, lineno: nil,
95-
context_line: nil, post_context: [], pre_context: []
94+
context_line: nil, post_context: [], pre_context: [],
95+
vars: %{},
9696
},
9797
%{
9898
module: :random,
9999
function: ":random.uniform/0",
100100
in_app: true,
101101
filename: nil, lineno: nil,
102-
context_line: nil, post_context: [], pre_context: []
102+
context_line: nil, post_context: [], pre_context: [],
103+
vars: %{},
103104
},
104105
%{
105106
module: :other_module,
106107
function: ":other_module.a_method/8",
107108
in_app: false,
108109
filename: nil, lineno: nil,
109-
context_line: nil, post_context: [], pre_context: []
110+
context_line: nil, post_context: [], pre_context: [],
111+
vars: %{},
110112
},
111113
%{
112114
module: Sentry,
113115
function: "Sentry.other_method/4",
114116
in_app: true,
115117
filename: nil, lineno: nil,
116-
context_line: nil, post_context: [], pre_context: []
118+
context_line: nil, post_context: [], pre_context: [],
119+
vars: %{},
117120
},
118121
%{
119122
filename: nil,
@@ -123,7 +126,8 @@ defmodule Sentry.EventTest do
123126
in_app: true,
124127
context_line: nil,
125128
post_context: [],
126-
pre_context: []
129+
pre_context: [],
130+
vars: %{},
127131
},
128132
]} == event.stacktrace
129133
end

test/logger_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ defmodule Sentry.LoggerTest do
9494
"context_line" => nil,
9595
"pre_context" => [],
9696
"post_context" => [],
97+
"vars" => %{"arg0" => "{}", "arg1" => "{0, 0}"}
9798
}
9899
assert conn.request_path == "/api/1/store/"
99100
assert conn.method == "POST"

0 commit comments

Comments
 (0)