Skip to content

Instantly share code, notes, and snippets.

@tony612
Created May 20, 2018 09:33
Show Gist options
  • Save tony612/12e74e056c236dfdd82f50e961e9bed6 to your computer and use it in GitHub Desktop.
Save tony612/12e74e056c236dfdd82f50e961e9bed6 to your computer and use it in GitHub Desktop.
sentry interceptor for grpc-elixir
defmodule GRPCSentry.ServerInterceptor do
@behaviour GRPC.ServerInterceptor
def init(opts), do: opts
def call(req, stream, next, _opts) do
result = next.(req, stream)
case result do
{:error, %{kind: kind, reason: reason, stack: stack}} ->
exception = Exception.normalize(kind, reason, stack)
Sentry.capture_exception(
exception,
stacktrace: stack,
event_source: :grpc,
error_type: kind
)
_ -> :ok
end
result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment