inspect terms that otherwise can't be serialized by exporter (#40)
This commit is contained in:
parent
9ce604153d
commit
f21b315e3e
|
@ -26,27 +26,27 @@ defmodule OpentelemetryPhoenix.Reason do
|
|||
|
||||
def normalize({:badarity, {fun, args}}) do
|
||||
{:arity, arity} = Function.info(fun, :arity)
|
||||
[reason: :badarity, function: "#{inspect(fun)}", arity: arity, args: args]
|
||||
[reason: :badarity, function: _inspect(fun), arity: arity, args: _inspect(args)]
|
||||
end
|
||||
|
||||
def normalize({:badfun, term}) do
|
||||
[reason: :badfun, term: term]
|
||||
[reason: :badfun, term: _inspect(term)]
|
||||
end
|
||||
|
||||
def normalize({:badstruct, struct, term}) do
|
||||
[reason: :badstruct, struct: struct, term: term]
|
||||
[reason: :badstruct, struct: struct, term: _inspect(term)]
|
||||
end
|
||||
|
||||
def normalize({:badmatch, term}) do
|
||||
[reason: :badmatch, term: term]
|
||||
[reason: :badmatch, term: _inspect(term)]
|
||||
end
|
||||
|
||||
def normalize({:badmap, term}) do
|
||||
[reason: :badmap, term: term]
|
||||
[reason: :badmap, term: _inspect(term)]
|
||||
end
|
||||
|
||||
def normalize({:badbool, op, term}) do
|
||||
[reason: :badbool, operator: op, term: term]
|
||||
[reason: :badbool, operator: op, term: _inspect(term)]
|
||||
end
|
||||
|
||||
def normalize({:badkey, key}) do
|
||||
|
@ -54,23 +54,23 @@ defmodule OpentelemetryPhoenix.Reason do
|
|||
end
|
||||
|
||||
def normalize({:badkey, key, map}) do
|
||||
[reason: :badkey, key: key, map: map]
|
||||
[reason: :badkey, key: key, map: _inspect(map)]
|
||||
end
|
||||
|
||||
def normalize({:case_clause, term}) do
|
||||
[reason: :case_clause, term: term]
|
||||
[reason: :case_clause, term: _inspect(term)]
|
||||
end
|
||||
|
||||
def normalize({:with_clause, term}) do
|
||||
[reason: :with_clause, term: term]
|
||||
[reason: :with_clause, term: _inspect(term)]
|
||||
end
|
||||
|
||||
def normalize({:try_clause, term}) do
|
||||
[reason: :try_clause, term: term]
|
||||
[reason: :try_clause, term: _inspect(term)]
|
||||
end
|
||||
|
||||
def normalize({:badarg, payload}) do
|
||||
[reason: :badarg, payload: payload]
|
||||
[reason: :badarg, payload: _inspect(payload)]
|
||||
end
|
||||
|
||||
def normalize(other) do
|
||||
|
@ -80,4 +80,12 @@ defmodule OpentelemetryPhoenix.Reason do
|
|||
def normalize(other, _stacktrace) do
|
||||
[reason: other]
|
||||
end
|
||||
|
||||
defp _inspect(term) do
|
||||
if String.Chars.impl_for(term) do
|
||||
term
|
||||
else
|
||||
inspect(term)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -140,7 +140,7 @@ defmodule OpentelemetryPhoenixTest do
|
|||
{"exception.message", "Erlang error: :badkey"},
|
||||
{"exception.stacktrace", _stacktrace},
|
||||
{:key, :name},
|
||||
{:map, %{username: "rick"}}
|
||||
{:map, "%{username: \"rick\"}"}
|
||||
]
|
||||
)
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue