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 +4 -4
- data/lib/raygun/apm/rails.rb +5 -0
- data/lib/raygun/apm/rails/middleware.rb +30 -12
- data/lib/raygun/apm/rails/railtie.rb +5 -1
- data/lib/raygun/apm/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79129467782cc432e61c5ea57a109612ad3e7e4d286e60e7a86d13d3f7b54df7
|
4
|
+
data.tar.gz: 714b18712b89e3b1b04c133456d7616b9e64fa075206c20407921927f8c97b29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e735bf886b0b92a85a621e1456e2d0fc0dab6b4dae4186460449f82fb90cb243cac36fdae4a17731f86ff306d7bed0adcea82a097b11ce962898e8243707715
|
7
|
+
data.tar.gz: 0b1d21a719042151dc3ac53f627c9547c73146fe75fe03a511fbd3f9977f243a9bd0f2f3dc59e6cafa95b379102f65ba6052b376255e93a4184e252201327e88
|
data/lib/raygun/apm/rails.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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 =
|
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] =
|
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
|
-
|
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 =
|
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] =
|
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
|
-
|
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
|
-
|
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
|
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.
|
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
|
+
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.
|
107
|
+
rubygems_version: 3.0.3
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Raygun application performance monitoring for Rails
|