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
|
def normalize({:badarity, {fun, args}}) do
|
||||||
{:arity, arity} = Function.info(fun, :arity)
|
{: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
|
end
|
||||||
|
|
||||||
def normalize({:badfun, term}) do
|
def normalize({:badfun, term}) do
|
||||||
[reason: :badfun, term: term]
|
[reason: :badfun, term: _inspect(term)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:badstruct, struct, term}) do
|
def normalize({:badstruct, struct, term}) do
|
||||||
[reason: :badstruct, struct: struct, term: term]
|
[reason: :badstruct, struct: struct, term: _inspect(term)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:badmatch, term}) do
|
def normalize({:badmatch, term}) do
|
||||||
[reason: :badmatch, term: term]
|
[reason: :badmatch, term: _inspect(term)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:badmap, term}) do
|
def normalize({:badmap, term}) do
|
||||||
[reason: :badmap, term: term]
|
[reason: :badmap, term: _inspect(term)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:badbool, op, term}) do
|
def normalize({:badbool, op, term}) do
|
||||||
[reason: :badbool, operator: op, term: term]
|
[reason: :badbool, operator: op, term: _inspect(term)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:badkey, key}) do
|
def normalize({:badkey, key}) do
|
||||||
|
@ -54,23 +54,23 @@ defmodule OpentelemetryPhoenix.Reason do
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:badkey, key, map}) do
|
def normalize({:badkey, key, map}) do
|
||||||
[reason: :badkey, key: key, map: map]
|
[reason: :badkey, key: key, map: _inspect(map)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:case_clause, term}) do
|
def normalize({:case_clause, term}) do
|
||||||
[reason: :case_clause, term: term]
|
[reason: :case_clause, term: _inspect(term)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:with_clause, term}) do
|
def normalize({:with_clause, term}) do
|
||||||
[reason: :with_clause, term: term]
|
[reason: :with_clause, term: _inspect(term)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:try_clause, term}) do
|
def normalize({:try_clause, term}) do
|
||||||
[reason: :try_clause, term: term]
|
[reason: :try_clause, term: _inspect(term)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize({:badarg, payload}) do
|
def normalize({:badarg, payload}) do
|
||||||
[reason: :badarg, payload: payload]
|
[reason: :badarg, payload: _inspect(payload)]
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize(other) do
|
def normalize(other) do
|
||||||
|
@ -80,4 +80,12 @@ defmodule OpentelemetryPhoenix.Reason do
|
||||||
def normalize(other, _stacktrace) do
|
def normalize(other, _stacktrace) do
|
||||||
[reason: other]
|
[reason: other]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp _inspect(term) do
|
||||||
|
if String.Chars.impl_for(term) do
|
||||||
|
term
|
||||||
|
else
|
||||||
|
inspect(term)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -140,7 +140,7 @@ defmodule OpentelemetryPhoenixTest do
|
||||||
{"exception.message", "Erlang error: :badkey"},
|
{"exception.message", "Erlang error: :badkey"},
|
||||||
{"exception.stacktrace", _stacktrace},
|
{"exception.stacktrace", _stacktrace},
|
||||||
{:key, :name},
|
{:key, :name},
|
||||||
{:map, %{username: "rick"}}
|
{:map, "%{username: \"rick\"}"}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue