Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add result to client telemetry spans #334

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/grpc/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ defmodule GRPC.Telemetry do
* `:function_name` - the name of the function called
* `:server` - the server module name
* `:endpoint` - the endpoint module name
* `:result` - the result returned from the interceptor pipeline.

`:exception` events also include some error metadata:

Expand Down Expand Up @@ -115,7 +116,9 @@ defmodule GRPC.Telemetry do

:telemetry.span(@client_rpc, start_metadata, fn ->
try do
{span_fn.(), start_metadata}
result = span_fn.()

{result, Map.put(start_metadata, :result, result)}
rescue
e ->
:erlang.error(Exception.normalize(:error, e, __STACKTRACE__))
Expand Down