raygun-apm-rails 0.1.3 → 0.1.8

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: 04470e2ef8a971fbd61675b771c0c10a6b95a6edb960526cf91c7ff244741b95
4
- data.tar.gz: f312f4010d321dbe54af892983e3438e086472f77855c633dcc8977dc956bbe0
3
+ metadata.gz: 79129467782cc432e61c5ea57a109612ad3e7e4d286e60e7a86d13d3f7b54df7
4
+ data.tar.gz: 714b18712b89e3b1b04c133456d7616b9e64fa075206c20407921927f8c97b29
5
5
  SHA512:
6
- metadata.gz: 4c3e1d70fa2af061757f42b36a9f39547a2086e9a6c09c97cc95d5031f3aadd22bb0083591a66a0331fcb62071bfd5ac4c17d2dca0207d577f3b2363155c1208
7
- data.tar.gz: cfe6f36919254d79510ec4eb1ed55e5312298b0cefc89da971a0c0ff7a6b2afe266e0a08cfe728a21f82bde76ba0e8e46180cf6065bc8fc898af39c6861bf3d0
6
+ metadata.gz: 9e735bf886b0b92a85a621e1456e2d0fc0dab6b4dae4186460449f82fb90cb243cac36fdae4a17731f86ff306d7bed0adcea82a097b11ce962898e8243707715
7
+ data.tar.gz: 0b1d21a719042151dc3ac53f627c9547c73146fe75fe03a511fbd3f9977f243a9bd0f2f3dc59e6cafa95b379102f65ba6052b376255e93a4184e252201327e88
@@ -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,7 +29,10 @@ 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.thread_variable_set(:_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
@@ -47,29 +50,37 @@ module Raygun
47
50
  @tracer.tracepoint.stop if @tracer.tracepoint.enabled?
48
51
  # Let the GC clean up the sink thread through the finalizer below
49
52
  @tracer = nil
53
+ Thread.current.thread_variable_set(:_raygun_apm_tracer, nil)
50
54
  end
51
55
 
52
56
  def http_in_handler(args)
53
57
  notification = ActiveSupport::Notifications::Event.new *args
54
58
  if notification.payload[:exception]
55
- # XXX notify?
59
+ warn "[Raygun APM] exception in HTTP IN event: #{notification.payload[:exception]}"
56
60
  return
57
61
  end
58
62
  req = Rack::Request.new notification.payload[:headers].env
59
- event = Raygun::Apm::Event::HttpIn.new
63
+ event = http_in_event
60
64
  event[:url] = req.url
61
65
  event[:verb] = req.request_method
62
66
  event[:status] = notification.payload[:status]
63
67
  # XXX constant milliseconds to microseconds
64
68
  event[:duration] = notification.duration * 1000
65
- event[:timestamp] = Time.now.to_f*1000000
66
- event[:pid] = Process.pid
69
+ event[:timestamp] = notification.time.to_f * 1000000
67
70
  event[:tid] = @tracer.get_thread_id(Thread.current)
68
71
  @tracer.emit(event)
69
72
  rescue => e
70
- # XXX report
73
+ warn "[Raygun APM] error reporting HTTP IN event"
71
74
  end
72
-
75
+
76
+ def http_in_event
77
+ @http_in_event ||= begin
78
+ event = Raygun::Apm::Event::HttpIn.new
79
+ event[:pid] = Process.pid
80
+ event
81
+ end
82
+ end
83
+
73
84
  def sql_handler(args)
74
85
  notification = ActiveSupport::Notifications::Event.new *args
75
86
  connection = if notification.payload[:connection]
@@ -77,7 +88,7 @@ module Raygun
77
88
  else
78
89
  ObjectSpace._id2ref(notification.payload[:connection_id])
79
90
  end
80
- event = Raygun::Apm::Event::Sql.new
91
+ event = sql_event
81
92
  event[:query] = notification.payload[:sql]
82
93
 
83
94
  # XXX this is hacky
@@ -89,14 +100,21 @@ module Raygun
89
100
 
90
101
  # XXX constant milliseconds to microseconds
91
102
  event[:duration] = notification.duration * 1000
92
- event[:timestamp] = Time.now.to_f*1000000
93
- event[:pid] = Process.pid
103
+ event[:timestamp] = notification.time.to_f * 1000000
94
104
  event[:tid] = @tracer.get_thread_id(Thread.current)
95
105
  @tracer.emit(event)
96
106
  rescue => e
97
- # XXX report
107
+ warn "[Raygun APM] error reporting SQL event"
98
108
  end
99
-
109
+
110
+ def sql_event
111
+ @sql_event ||= begin
112
+ event = Raygun::Apm::Event::Sql.new
113
+ event[:pid] = Process.pid
114
+ event
115
+ end
116
+ end
117
+
100
118
  def self.finalize(tracer)
101
119
  proc {tracer.process_ended}
102
120
  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.3"
4
+ VERSION = "0.1.8"
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.3
4
+ version: 0.1.8
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-28 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.1.0.pre3
107
+ rubygems_version: 3.0.3
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Raygun application performance monitoring for Rails