Sha256: 827f40fe5209cc5d6c2b1fe2b1e02ca64e600e475d8d1fa1328c4455cda1126a
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
module ILove module Tracing module Twirp def self.setup(cfg) raise 'Cannot trace twirp without twirp_rails gem' unless defined?(::TwirpRails) ::TwirpRails::Routes::Helper.on_create_service do |service| trace_service service end end def self.trace_service(service) scope = nil service.before do |_rack_env, env| method_name = env[:rpc_method] scope = OpenTracing.start_active_span 'twirp call', child_of: OpenTracing.active_span, tags: { service: service.full_name, method: method_name } end service.on_error do |err, _env| if scope scope.span.set_tag :error_code, err.code scope.span.set_tag :error_msg, err.msg scope.close scope = nil end end service.on_success do |_env| if scope scope.close scope = nil end end service.exception_raised do |e, _env| if scope scope.span.set_tag :exception, e.class.name scope.close scope = nil end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ilove-tracing-0.2.0 | lib/ilove/tracing/twirp.rb |