raygun-apm-rails 0.1.6 → 0.1.11

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: 5bded6633ee12299036cbbc4335ab2d2332375299aa2746c507801791cc0b886
4
- data.tar.gz: 5e4e99d585dfe5e1b970c4857088ad2fec161f7935677e9b3545b947b7164ee6
3
+ metadata.gz: 5900138251a3565aed5ea97e891612937933fc6332848e67c29b3cb383d5bfd9
4
+ data.tar.gz: d55c239c8204734478c954f4d1eb771450bc0833a4dd6a47591ca1b1caa3820a
5
5
  SHA512:
6
- metadata.gz: 18a5b450114214cfb18be5de0091e5cf93ef8c59e0f5d37103d3e641b650e6855fac6c59668170b0b6b3888aa6d51d4f5c466912e050331c0f10f7ef7c1c2610
7
- data.tar.gz: 2439fa20850563b3be76f8ffab6c362250d452388cd309c8f5d6a0cd62261a56c9620a022a60bda54db405be97a5e41af6e8f2153206b2982d22a6ec068c23a4
6
+ metadata.gz: b8cba67519311b80693f8dc5f16564c8556ec9da2d7d3227c5a3e6680ff7882e1fd95c9b0e30df47a18821617ccb2fc06e713d9b1ce4d0cf4e93582d9c5fa015
7
+ data.tar.gz: 40c4f280a7f1aa7d83587eae23a37114bef346518fbbff9e62f6bb1bd68f0e57aee8ba1c956036bbd27e0cb75756639849a5cf8b3b5ac5084af846fd4a76eca3
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
@@ -70,4 +70,6 @@ module Raygun
70
70
  end
71
71
  end
72
72
 
73
- require "raygun/apm/rails/railtie" if defined?(::Rails)
73
+ if defined?(::Rails) && !ENV['RAYGUN_SKIP_MIDDLEWARE']
74
+ require "raygun/apm/rails/railtie"
75
+ 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,6 +50,7 @@ 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)
@@ -56,20 +60,27 @@ module Raygun
56
60
  return
57
61
  end
58
62
  req = Rack::Request.new notification.payload[:headers].env
59
- @http_in_event ||= Raygun::Apm::Event::HttpIn.new
60
- @http_in_event[:url] = req.url
61
- @http_in_event[:verb] = req.request_method
62
- @http_in_event[:status] = notification.payload[:status]
63
+ event = http_in_event
64
+ event[:url] = req.url
65
+ event[:verb] = req.request_method
66
+ event[:status] = notification.payload[:status]
63
67
  # XXX constant milliseconds to microseconds
64
- @http_in_event[:duration] = notification.duration * 1000
65
- @http_in_event[:timestamp] = notification.time.to_f * 1000000
66
- @http_in_event[:pid] = Process.pid
67
- @http_in_event[:tid] = @tracer.get_thread_id(Thread.current)
68
- @tracer.emit(@http_in_event)
68
+ event[:duration] = notification.duration * 1000
69
+ event[:timestamp] = notification.time.to_f * 1000000
70
+ event[:tid] = @tracer.get_thread_id(Thread.current)
71
+ @tracer.emit(event)
69
72
  rescue => e
70
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,26 +88,33 @@ module Raygun
77
88
  else
78
89
  ObjectSpace._id2ref(notification.payload[:connection_id])
79
90
  end
80
- @sql_event ||= Raygun::Apm::Event::Sql.new
81
- @sql_event[:query] = notification.payload[:sql]
91
+ event = sql_event
92
+ event[:query] = notification.payload[:sql]
82
93
 
83
94
  # XXX this is hacky
84
95
  if config = connection.instance_variable_get('@config')
85
- @sql_event[:provider] = config[:adapter]
86
- @sql_event[:host] = config[:host]
87
- @sql_event[:database] = config[:database]
96
+ event[:provider] = config[:adapter]
97
+ event[:host] = config[:host]
98
+ event[:database] = config[:database]
88
99
  end
89
100
 
90
101
  # XXX constant milliseconds to microseconds
91
- @sql_event[:duration] = notification.duration * 1000
92
- @sql_event[:timestamp] = notification.time.to_f * 1000000
93
- @sql_event[:pid] = Process.pid
94
- @sql_event[:tid] = @tracer.get_thread_id(Thread.current)
95
- @tracer.emit(@sql_event)
102
+ event[:duration] = notification.duration * 1000
103
+ event[:timestamp] = notification.time.to_f * 1000000
104
+ event[:tid] = @tracer.get_thread_id(Thread.current)
105
+ @tracer.emit(event)
96
106
  rescue => e
97
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
@@ -8,6 +8,8 @@ module Raygun
8
8
  Raygun::Apm::Blacklist.extend_with Raygun::Apm::Rails::BLACKLIST
9
9
  Raygun::Apm::Blacklist.extend_with Raygun::Apm::Rails::BOUNDARY
10
10
  app.middleware.insert_before Rack::Sendfile, Raygun::Apm::Rails::Middleware
11
+ # Explictly enable instrumenting HTTP until a good control API is figured out
12
+ require "raygun/apm/hooks/net_http"
11
13
  end
12
14
  end
13
15
  end
@@ -1,7 +1,7 @@
1
1
  module Raygun
2
2
  module Apm
3
3
  module Rails
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.11"
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.6
4
+ version: 0.1.11
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-12-09 00:00:00.000000000 Z
11
+ date: 2019-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raygun-apm