Skip to content

Commit 4ee5f27

Browse files
committed
include args if there are any under vars
1 parent d69fc02 commit 4ee5f27

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

lib/sentry/event.ex

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

9191
env = Config.environment_name()
92+
f_args = args_from_stacktrace(stacktrace)
9293

9394
%Event{
9495
culprit: culprit_from_stacktrace(stacktrace),
@@ -99,7 +100,8 @@ defmodule Sentry.Event do
99100
server_name: server_name,
100101
exception: exception,
101102
stacktrace: %{
102-
frames: stacktrace_to_frames(stacktrace)
103+
frames: stacktrace_to_frames(stacktrace),
104+
vars: f_args,
103105
},
104106
release: release,
105107
extra: extra,
@@ -170,8 +172,8 @@ defmodule Sentry.Event do
170172
in_app_module_whitelist = Config.in_app_module_whitelist()
171173
stacktrace
172174
|> Enum.map(fn(line) ->
173-
{mod, function, arity, location} = line
174-
arity = arity_to_integer(arity)
175+
{mod, function, arity_or_args, location} = line
176+
arity = arity_to_integer(arity_or_args)
175177
file = Keyword.get(location, :file)
176178
file = if(file, do: String.Chars.to_string(file), else: file)
177179
line_number = Keyword.get(location, :line)
@@ -202,7 +204,24 @@ defmodule Sentry.Event do
202204

203205
@spec culprit_from_stacktrace(Exception.stacktrace) :: String.t | nil
204206
def culprit_from_stacktrace([]), do: nil
205-
def culprit_from_stacktrace([{m, f, a, _} | _]), do: Exception.format_mfa(m, f, a)
207+
def culprit_from_stacktrace([{m, f, a, _} | _]) do
208+
Exception.format_mfa(m, f, arity_to_integer(a))
209+
end
210+
211+
@doc """
212+
Builds a map from argument value list. For Sentry, typically the
213+
key in the map would be the name of the variable, but we don't have that
214+
available.
215+
"""
216+
@spec args_from_stacktrace(Exception.stacktrace) :: String.t | nil
217+
def args_from_stacktrace([{_m, _f, a, _} | _]) when is_list(a) do
218+
Enum.with_index(a)
219+
|> Enum.map(fn({arg, index}) ->
220+
{"arg#{index}", inspect(arg)}
221+
end)
222+
|> Enum.into(%{})
223+
end
224+
def args_from_stacktrace(_), do: %{}
206225

207226
defp arity_to_integer(arity) when is_list(arity), do: Enum.count(arity)
208227
defp arity_to_integer(arity) when is_integer(arity), do: arity

0 commit comments

Comments
 (0)