Skip to content

Commit

Permalink
fixup! Add record_exception to Erlang
Browse files Browse the repository at this point in the history
  • Loading branch information
gugahoa committed Nov 29, 2020
1 parent fd12c88 commit 3b03145
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions apps/opentelemetry/test/opentelemetry_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ record_exception_works(Config) ->
[Span] = assert_exported(Tid, SpanCtx),
[Event] = Span#span.events,
?assertEqual(<<"exception">>, Event#event.name),
?assertEqual([{<<"exception.type">>, ["throw",58,"my_error"]},
{<<"exception.stacktrace">>, io_lib:format("~p", [Stacktrace])},
?assertEqual([{<<"exception.type">>, <<"throw:my_error">>},
{<<"exception.stacktrace">>, list_to_binary(io_lib:format("~p", [Stacktrace]))},
{"some-attribute","value"}],
Event#event.attributes),
ok
Expand All @@ -488,8 +488,8 @@ record_exception_with_message_works(Config) ->
[Span] = assert_exported(Tid, SpanCtx),
[Event] = Span#span.events,
?assertEqual(<<"exception">>, Event#event.name),
?assertEqual([{<<"exception.type">>, ["throw",58,"my_error"]},
{<<"exception.stacktrace">>, io_lib:format("~p", [Stacktrace])},
?assertEqual([{<<"exception.type">>, <<"throw:my_error">>},
{<<"exception.stacktrace">>, list_to_binary(io_lib:format("~p", [Stacktrace]))},
{<<"exception.message">>, "My message"},
{"some-attribute","value"}],
Event#event.attributes),
Expand Down
8 changes: 4 additions & 4 deletions apps/opentelemetry_api/src/otel_span.erl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ add_events(_, _) ->
Stacktrace :: list(any()),
Attributes :: opentelemetry:attributes().
record_exception(SpanCtx, Class, Term, Stacktrace, Attributes) ->
ExceptionAttributes = [{<<"exception.type">>, io_lib:format("~p:~p", [Class, Term])},
{<<"exception.stacktrace">>, io_lib:format("~p", [Stacktrace])}],
ExceptionAttributes = [{<<"exception.type">>, list_to_binary(io_lib:format("~p:~p", [Class, Term]))},
{<<"exception.stacktrace">>, list_to_binary(io_lib:format("~p", [Stacktrace]))}],
add_event(SpanCtx, <<"exception">>, ExceptionAttributes ++ Attributes).

-spec record_exception(SpanCtx, Class, Term, Message, Stacktrace, Attributes) -> boolean() when
Expand All @@ -126,8 +126,8 @@ record_exception(SpanCtx, Class, Term, Stacktrace, Attributes) ->
Stacktrace :: list(any()),
Attributes :: opentelemetry:attributes().
record_exception(SpanCtx, Class, Term, Message, Stacktrace, Attributes) ->
ExceptionAttributes = [{<<"exception.type">>, io_lib:format("~p:~p", [Class, Term])},
{<<"exception.stacktrace">>, io_lib:format("~p", [Stacktrace])},
ExceptionAttributes = [{<<"exception.type">>, list_to_binary(io_lib:format("~p:~p", [Class, Term]))},
{<<"exception.stacktrace">>, list_to_binary(io_lib:format("~p", [Stacktrace]))},
{<<"exception.message">>, Message}],
add_event(SpanCtx, <<"exception">>, ExceptionAttributes ++ Attributes).

Expand Down

0 comments on commit 3b03145

Please sign in to comment.