Created
May 20, 2018 09:33
-
-
Save tony612/12e74e056c236dfdd82f50e961e9bed6 to your computer and use it in GitHub Desktop.
sentry interceptor for grpc-elixir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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