14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/twirp_rails/logging_adapter.rb', line 14
def self.instrument(service)
instrumenter = ActiveSupport::Notifications.instrumenter
service.before do |rack_env, env|
payload = {
rack_env: rack_env,
env: env
}
instrumenter.start 'instrumenter.twirp', payload
end
service.on_error do |_twerr, _env|
instrumenter.finish 'instrumenter.twirp', {}
end
service.on_success do |_env|
instrumenter.finish 'instrumenter.twirp', {}
end
service.exception_raised do |e, env|
env[:exception] = {
class: e.class,
message: e.message,
backtrace: e.backtrace.join("\n")
}
end
end
|