raygun-apm-rails 0.1.2 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a20f7f7435a8a195b4b71ff5214d82b0d6c36c01d450be352db7d78bbf256838
4
- data.tar.gz: 9ab514ebf6e2e45593f6180fb054ef052c5099d3757cdd46ee4751028e942345
3
+ metadata.gz: a2d31d0ad976f35bdac2a42c3ae4b0da985291ab2a36e60982de8e04e2d34e7c
4
+ data.tar.gz: 582ec4542445a59adc1f33e76353c667153cc5e7af889a8f34a55213ef6e4564
5
5
  SHA512:
6
- metadata.gz: e659e34dab54a4255f63eba7e63743842eb6c6ef743597a4aad73ab4df5c3d7dbfa5243fd12b165cd55053d1b8ecbcf7f80dc8362d4967e0155b9b74f7985947
7
- data.tar.gz: b76504129b9507ea3f415627215e0006a7a379e3232aa3730d2057595a1be96596f5793e961caf46b03a8316287a37b1a756c7bdeebcc96dddbe67b83cb1c30a
6
+ metadata.gz: 757a3a0f926195c155aabaea9c29ee716b6d408d1c401440db9348fde89209c4bf919284752d715674ecd5b163b3f330706156aa215d2c8d5a167741a468bd41
7
+ data.tar.gz: e390eee50d733103fef5b025f6f8710689bf4235e956800ecd73791355e318452799eb43d87be4e825c11e1cc6768fa2c23b781614439c3a9d7d89053d112df7
@@ -59,8 +59,13 @@ module Raygun
59
59
  RequestStore
60
60
  WEBrick
61
61
  Puma
62
+ PG
63
+ EnabledModule
62
64
  }
63
65
 
66
+ BOUNDARY = %w{
67
+ +RequestStore::Middleware::call
68
+ }
64
69
  end
65
70
  end
66
71
  end
@@ -29,12 +29,15 @@ module Raygun
29
29
  def instrument(env)
30
30
  res = nil
31
31
  # Can be nil if we had a fatal error
32
- @tracer.start_trace if @tracer
32
+ if @tracer
33
+ Thread.current[:_raygun_apm_tracer] = @tracer
34
+ @tracer.start_trace
35
+ end
33
36
  res = @app.call(env)
34
37
  # Can be nil if we had a fatal error
35
38
  @tracer.end_trace if @tracer
36
39
  res
37
- rescue Raygun::APM::FatalError => e
40
+ rescue Raygun::Apm::FatalError => e
38
41
  raygun_shutdown_handler(e)
39
42
  end
40
43
 
@@ -46,30 +49,37 @@ module Raygun
46
49
  # Shutdown the tracepoint if enabled to reduce any overhead and stall emission
47
50
  @tracer.tracepoint.stop if @tracer.tracepoint.enabled?
48
51
  # Let the GC clean up the sink thread through the finalizer below
49
- @tracer = nil
52
+ @tracer = Thread.current[:_raygun_apm_tracer] = nil
50
53
  end
51
54
 
52
55
  def http_in_handler(args)
53
56
  notification = ActiveSupport::Notifications::Event.new *args
54
57
  if notification.payload[:exception]
55
- # XXX notify?
58
+ warn "[Raygun APM] exception in HTTP IN event: #{notification.payload[:exception]}"
56
59
  return
57
60
  end
58
61
  req = Rack::Request.new notification.payload[:headers].env
59
- event = Raygun::Apm::Event::HttpIn.new
62
+ event = http_in_event
60
63
  event[:url] = req.url
61
64
  event[:verb] = req.request_method
62
65
  event[:status] = notification.payload[:status]
63
66
  # XXX constant milliseconds to microseconds
64
67
  event[:duration] = notification.duration * 1000
65
- event[:timestamp] = Time.now.to_f*1000000
66
- event[:pid] = Process.pid
68
+ event[:timestamp] = notification.time.to_f * 1000000
67
69
  event[:tid] = @tracer.get_thread_id(Thread.current)
68
70
  @tracer.emit(event)
69
71
  rescue => e
70
- # XXX report
72
+ warn "[Raygun APM] error reporting HTTP IN event"
71
73
  end
72
-
74
+
75
+ def http_in_event
76
+ @http_in_event ||= begin
77
+ event = Raygun::Apm::Event::HttpIn.new
78
+ event[:pid] = Process.pid
79
+ event
80
+ end
81
+ end
82
+
73
83
  def sql_handler(args)
74
84
  notification = ActiveSupport::Notifications::Event.new *args
75
85
  connection = if notification.payload[:connection]
@@ -77,7 +87,7 @@ module Raygun
77
87
  else
78
88
  ObjectSpace._id2ref(notification.payload[:connection_id])
79
89
  end
80
- event = Raygun::Apm::Event::Sql.new
90
+ event = sql_event
81
91
  event[:query] = notification.payload[:sql]
82
92
 
83
93
  # XXX this is hacky
@@ -89,14 +99,21 @@ module Raygun
89
99
 
90
100
  # XXX constant milliseconds to microseconds
91
101
  event[:duration] = notification.duration * 1000
92
- event[:timestamp] = Time.now.to_f*1000000
93
- event[:pid] = Process.pid
102
+ event[:timestamp] = notification.time.to_f * 1000000
94
103
  event[:tid] = @tracer.get_thread_id(Thread.current)
95
104
  @tracer.emit(event)
96
105
  rescue => e
97
- # XXX report
106
+ warn "[Raygun APM] error reporting SQL event"
98
107
  end
99
-
108
+
109
+ def sql_event
110
+ @sql_event ||= begin
111
+ event = Raygun::Apm::Event::Sql.new
112
+ event[:pid] = Process.pid
113
+ event
114
+ end
115
+ end
116
+
100
117
  def self.finalize(tracer)
101
118
  proc {tracer.process_ended}
102
119
  end
@@ -3,10 +3,14 @@ module Raygun
3
3
  module Rails
4
4
  class Railtie < ::Rails::Railtie
5
5
  initializer "raygun.apm" do |app|
6
+ return if ENV['RAYGUN_SKIP_MIDDLEWARE']
6
7
  require "raygun/apm"
7
8
  require "raygun/apm/rails/middleware"
8
9
  Raygun::Apm::Blacklist.extend_with Raygun::Apm::Rails::BLACKLIST
9
- app.middleware.use Raygun::Apm::Rails::Middleware
10
+ Raygun::Apm::Blacklist.extend_with Raygun::Apm::Rails::BOUNDARY
11
+ app.middleware.insert_before Rack::Sendfile, Raygun::Apm::Rails::Middleware
12
+ # Explictly enable instrumenting HTTP until a good control API is figured out
13
+ require "raygun/apm/hooks/net_http"
10
14
  end
11
15
  end
12
16
  end
@@ -1,7 +1,7 @@
1
1
  module Raygun
2
2
  module Apm
3
3
  module Rails
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.7"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raygun-apm-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erkki Eilonen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-24 00:00:00.000000000 Z
11
+ date: 2019-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raygun-apm
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.0.6
107
+ rubygems_version: 3.0.3
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Raygun application performance monitoring for Rails