app_perf_rpm 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03668af4eec144bc020d7ad3e75731c474eb702c
4
- data.tar.gz: 2c66bd298f6d8a78eee735b0e1b18ab8ca2c9a1e
3
+ metadata.gz: c3acd152efd84397682641dd381b931c8a005251
4
+ data.tar.gz: 3f6b8ee3b1bc73675323e7050791511b725a2360
5
5
  SHA512:
6
- metadata.gz: a5581a8208d90f7935b28c6888e54918381bfeda18276c04c3db3f01ac7191f9c33c042b470299d517d402452c080a981796cb149aae9afb7cf727ee000e0047
7
- data.tar.gz: 3c4133f4d69eb65caa13f4cf1cbf764eb91ce6f8e6111c27d34f439164ab6737b34ad3cb4ae35c2e5e7b5c2f7c18e5929d0a50ea403b78074620232bc109f981
6
+ metadata.gz: d60c4242d0f5d71a614bffba15b140a3d05b9b98a8eef9b51d080786802a31ab8bb34cdf69549c03445ae9e6aeb033f7d55caf0f0781291ab79604309b9020ed
7
+ data.tar.gz: 13ca881a617b1af03acc08c3a579de2678c240c0a746c77e2633417ad8a42678422e5a5e56b8548e387298653078d06ce5c08c836bf5449ffa4c51ad1de2cc6e
@@ -33,6 +33,7 @@ module AppPerfRpm
33
33
  self.ignore_paths ||= /\/assets/
34
34
  self.instrumentation = {
35
35
  :rack => { :enabled => true, :backtrace => :app, :source => true, :trace_middleware => false },
36
+ :roda => { :enabled => true, :backtrace => :app, :source => true },
36
37
  :active_record => { :enabled => true, :backtrace => :app, :source => true },
37
38
  :active_record_import => { :enabled => true, :backtrace => :app, :source => true },
38
39
  :active_model_serializer => { :enabled => true, :backtrace => :app, :source => true },
@@ -0,0 +1,46 @@
1
+ module AppPerf
2
+ module Instruments
3
+ module Roda
4
+ def call_with_trace(&block)
5
+ if AppPerfRpm::Tracer.tracing?
6
+ req = ::Rack::Request.new(env)
7
+ request_method = req.request_method.to_s.upcase
8
+ path = req.path
9
+
10
+ parts = path.to_s.rpartition("/")
11
+ action = parts.last
12
+ controller = parts.first.sub(/\A\//, '').split("/").collect {|w| w.capitalize }.join("::")
13
+ operation = "#{controller}##{action}"
14
+
15
+ span = AppPerfRpm.tracer.start_span(operation, tags: {
16
+ "component" => "Roda",
17
+ "http.url" => path,
18
+ "http.method" => request_method,
19
+ "params" => @_request.params
20
+ })
21
+ AppPerfRpm::Utils.log_source_and_backtrace(span, :roda)
22
+ end
23
+
24
+ call_without_trace(&block)
25
+ rescue Exception => e
26
+ if span
27
+ span.set_tag('error', true)
28
+ span.log_error(e)
29
+ end
30
+ raise
31
+ ensure
32
+ span.finish if span
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ if defined?(::Roda) && ::AppPerfRpm.config.instrumentation[:roda][:enabled]
39
+ ::AppPerfRpm.logger.info "Initializing roda tracer."
40
+
41
+ ::Roda::RodaPlugins::Base::InstanceMethods.send(:include, AppPerf::Instruments::Roda)
42
+ ::Roda::RodaPlugins::Base::InstanceMethods.class_eval do
43
+ alias_method :call_without_trace, :call
44
+ alias_method :call, :call_with_trace
45
+ end
46
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_perf_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randy Girard
@@ -173,6 +173,7 @@ files:
173
173
  - lib/app_perf_rpm/instruments/net_http.rb
174
174
  - lib/app_perf_rpm/instruments/rack.rb
175
175
  - lib/app_perf_rpm/instruments/redis.rb
176
+ - lib/app_perf_rpm/instruments/roda.rb
176
177
  - lib/app_perf_rpm/instruments/sequel.rb
177
178
  - lib/app_perf_rpm/instruments/sidekiq.rb
178
179
  - lib/app_perf_rpm/instruments/sinatra.rb