raygun-apm-rails 0.1.4 → 0.1.9
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/Gemfile.lock +3 -3
- data/lib/raygun/apm/rails.rb +8 -1
- data/lib/raygun/apm/rails/middleware.rb +28 -10
- data/lib/raygun/apm/rails/railtie.rb +4 -1
- data/lib/raygun/apm/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa53ae0598b0601ba844ef77ff80a042e8628b9551a590e265e82e9c2bf0cd78
|
4
|
+
data.tar.gz: c95e195db693817411f1805be7d85b4a271352fe88c6e73bb72dc57d69e98c93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d89a784f58917e98401d808c035353f0ce3139946570f16ae192cb27fd83483498a0cf273db4e53ea7a4d441b5435f0b71ac34d9d18a3e22c01e5cd48b71cf74
|
7
|
+
data.tar.gz: 7b73837c1567d65b35d2190aff6c29044fde13d292b73eb379407bf6e94322c4cfb669d0a4d654cf6e3db07a6e1a7878f4fdff23f1e8e2db89abb854a694627c
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
raygun-apm-rails (0.1.
|
5
|
-
raygun-apm (~> 0.0.
|
4
|
+
raygun-apm-rails (0.1.0)
|
5
|
+
raygun-apm (~> 0.0.8)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
minitest (5.13.0)
|
11
11
|
rake (10.5.0)
|
12
|
-
raygun-apm (0.0.
|
12
|
+
raygun-apm (0.0.8-x86-linux)
|
13
13
|
|
14
14
|
PLATFORMS
|
15
15
|
ruby
|
data/lib/raygun/apm/rails.rb
CHANGED
@@ -59,10 +59,17 @@ 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
|
67
72
|
|
68
|
-
|
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
|
-
|
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
69
|
event[:timestamp] = notification.time.to_f * 1000000
|
66
|
-
event[:pid] = Process.pid
|
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
|
@@ -90,13 +101,20 @@ module Raygun
|
|
90
101
|
# XXX constant milliseconds to microseconds
|
91
102
|
event[:duration] = notification.duration * 1000
|
92
103
|
event[:timestamp] = notification.time.to_f * 1000000
|
93
|
-
event[:pid] = Process.pid
|
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
|
@@ -6,7 +6,10 @@ module Raygun
|
|
6
6
|
require "raygun/apm"
|
7
7
|
require "raygun/apm/rails/middleware"
|
8
8
|
Raygun::Apm::Blacklist.extend_with Raygun::Apm::Rails::BLACKLIST
|
9
|
-
|
9
|
+
Raygun::Apm::Blacklist.extend_with Raygun::Apm::Rails::BOUNDARY
|
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"
|
10
13
|
end
|
11
14
|
end
|
12
15
|
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.9
|
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-
|
11
|
+
date: 2019-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raygun-apm
|