Sha256: 34a683c653e3b983ade2e1af74e488853ff6fe22aad124fbdb4fb9062d9b7fe5
Contents?: true
Size: 1015 Bytes
Versions: 16
Compression:
Stored size: 1015 Bytes
Contents
# frozen_string_literal: true require 'twirp_rails/routes' module TwirpRails module LoggingAdapter # :nodoc: def self.install return unless defined?(ActiveSupport::Notifications) TwirpRails::Routes::Helper.on_create_service do |service| LoggingAdapter.instrument service end end 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 end end
Version data entries
16 entries across 16 versions & 1 rubygems