raygun-apm 0.0.24-x86-linux → 0.0.25-x86-linux

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: f232a5551aa8bae66f4f97979a020340b34afb28d1a830d2ba7a4427f46f6822
4
- data.tar.gz: 6cdda6193dadedda970dd2d33d93d76f078855ded47be5ba6545faa44ed20cf0
3
+ metadata.gz: 809f0f4cfbe979d874a6c8df5e047c1dc63d28d9d4249db7ee05c8cc6aa86338
4
+ data.tar.gz: 770f09d6ba17cd618d486000cd901c0ef5dd3bb86da817192e47b560be48fbc7
5
5
  SHA512:
6
- metadata.gz: 383faa6a263208b30003f9dc97e03b9c0487d12d63953608ece060770d4802395c48c3cb61c362f2f49be680665b2b5eda34646a86f5a570d723abf3f6795b7d
7
- data.tar.gz: 9a15cccdfae016dc0bbf840762eed76dd6eabaac1ccad3851f2aff6b5bd24eebc82aff0f248dce272071b2f971a9520f9ccb90c674b9fece53e74bf5c9f13219
6
+ metadata.gz: 6961a015e842d07551df9bd828726f67ef0833407bd2f3c138c2459841f9fe21dac5494d9fa27a7a273d187c5295486fd83641c67cf1ea280d942b7f171bdddc
7
+ data.tar.gz: d4499c56b1afd8364986c17277f4735cc5ebecf03ee0543945d20432e70dc8abd5401ff6fcc72b84f270eb4928273516cd83c00a1a1f9ba1a2d313b59ac71fcc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- raygun-apm (0.0.24)
4
+ raygun-apm (0.0.25)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -30,4 +30,4 @@ DEPENDENCIES
30
30
  raygun-apm!
31
31
 
32
32
  BUNDLED WITH
33
- 2.1.0
33
+ 2.1.2
data/README.rdoc CHANGED
@@ -75,7 +75,7 @@ Extended events can be sent where appropiate
75
75
  event = Raygun::Apm::Event::HttpIn.new
76
76
  event[:pid] = Process.pid
77
77
  event[:tid] = 0
78
- event[:timestamp] = Time.now.to_f*1000000
78
+ event[:timestamp] = tracer.now
79
79
  event[:url] = 'https://google.com/'
80
80
  event[:verb] = 'GET'
81
81
  event[:status] = 200
@@ -87,7 +87,7 @@ Extended events can be sent where appropiate
87
87
  event = Raygun::Apm::Event::Sql.new
88
88
  event[:pid] = Process.pid
89
89
  event[:tid] = 0
90
- event[:timestamp] = Time.now.to_f*1000000
90
+ event[:timestamp] = tracer.now
91
91
  event[:provider] = 'postgres'
92
92
  event[:host] = 'localhost'
93
93
  event[:database] = 'rails'
Binary file
Binary file
@@ -136,6 +136,9 @@ module Raygun
136
136
  Warning
137
137
  ZeroDivisionError
138
138
  IPAddr
139
+ Net::
140
+ OpenSSL
141
+ BasicSocket
139
142
  }
140
143
 
141
144
  def self.extend_with(list)
@@ -0,0 +1,46 @@
1
+ require 'net/http'
2
+
3
+ module Raygun
4
+ module Apm
5
+ module Hooks
6
+ module Net
7
+ module HTTP
8
+ private
9
+
10
+ def transport_request(request)
11
+ if tracer = raygun_apm_tracer
12
+ started = tracer.now
13
+ response = super
14
+ ended = tracer.now
15
+ event = raygun_apm_http_out_event
16
+ event[:url] = request.uri.to_s
17
+ event[:verb] = request.method
18
+ event[:status] = response.code.to_i
19
+ event[:duration] = ended - started
20
+ event[:timestamp] = started
21
+ event[:tid] = tracer.get_thread_id(Thread.current)
22
+ tracer.emit(event)
23
+ response
24
+ else
25
+ super
26
+ end
27
+ end
28
+
29
+ def raygun_apm_http_out_event
30
+ @_raygun_apm_http_out_event ||= begin
31
+ event = Raygun::Apm::Event::HttpOut.new
32
+ event[:pid] = Process.pid
33
+ event
34
+ end
35
+ end
36
+
37
+ def raygun_apm_tracer
38
+ Thread.current.thread_variable_get(:_raygun_apm_tracer)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ ::Net::HTTP.prepend(Raygun::Apm::Hooks::Net::HTTP)
@@ -1,5 +1,5 @@
1
1
  module Raygun
2
2
  module Apm
3
- VERSION = "0.0.24"
3
+ VERSION = "0.0.25"
4
4
  end
5
5
  end
data/lib/raygun/apm.rb CHANGED
@@ -11,6 +11,5 @@ require "raygun/apm/event"
11
11
 
12
12
  module Raygun
13
13
  module Apm
14
- # Your code goes here...
15
14
  end
16
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raygun-apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: x86-linux
6
6
  authors:
7
7
  - Erkki Eilonen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-19 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: debase-ruby_core_source
@@ -127,7 +127,7 @@ files:
127
127
  - lib/raygun/apm/blacklist.rb
128
128
  - lib/raygun/apm/config.rb
129
129
  - lib/raygun/apm/event.rb
130
- - lib/raygun/apm/middleware.rb
130
+ - lib/raygun/apm/hooks/net_http.rb
131
131
  - lib/raygun/apm/tracer.rb
132
132
  - lib/raygun/apm/version.rb
133
133
  - raygun-apm.gemspec
@@ -1,104 +0,0 @@
1
- module Raygun
2
- module Apm
3
- class Middleware
4
- def initialize(app)
5
- @app = app
6
- @tracer = Raygun::Apm::Tracer.new
7
- @tracer.udp_sink!
8
- @tracer.process_started
9
- ObjectSpace.define_finalizer(self, self.class.finalize(@tracer))
10
-
11
- @http_in_subscriber = ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
12
- http_in_handler(args)
13
- end
14
- @sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
15
- sql_handler(args)
16
- end
17
-
18
- # If any kamikaze errors on init, shutdown the tracer
19
- rescue Raygun::Apm::FatalError => e
20
- kamikaze_handler(e)
21
- end
22
-
23
- def call(env)
24
- @status, @headers, @response = instrument(env)
25
- [@status, @headers, @response]
26
- end
27
-
28
- def instrument(env)
29
- res = nil
30
- # Can be nil if we had a kamikaze error
31
- @tracer.start_trace if @tracer
32
- res = @app.call(env)
33
- # Can be nil if we had a kamikaze error
34
- @tracer.end_trace if @tracer
35
- res
36
- rescue Raygun::Apm::FatalError => e
37
- kamikaze_handler(e)
38
- end
39
-
40
- def kamikaze_handler(exception)
41
- warn "Raygun APM shutting down due to error - %s", e.message
42
- # Kill extended event subcriptions
43
- ActiveSupport::Notifications.unsubscribe(@http_in_subscriber)
44
- ActiveSupport::Notifications.unsubscribe(@sql_subscriber)
45
- # Shutdown the tracepoint if enabled to reduce any overhead and stall emission
46
- @tracer.tracepoint.stop if @tracer.tracepoint.enabled?
47
- # Let the GC clean up the sink thread through the finalizer below
48
- @tracer = nil
49
- end
50
-
51
- def http_in_handler(args)
52
- notification = ActiveSupport::Notifications::Event.new *args
53
- if notification.payload[:exception]
54
- # XXX notify?
55
- return
56
- end
57
- req = Rack::Request.new notification.payload[:headers].env
58
- event = Raygun::Apm::Event::HttpIn.new
59
- event[:url] = req.url
60
- event[:verb] = req.request_method
61
- event[:status] = notification.payload[:status]
62
- # XXX constant milliseconds to microseconds
63
- event[:duration] = notification.duration * 1000
64
- event[:timestamp] = notification.time.to_f*1000000
65
- event[:pid] = Process.pid
66
- event[:tid] = @tracer.get_thread_id(Thread.current)
67
- @tracer.emit(event)
68
- rescue => e
69
- # XXX report
70
- end
71
-
72
- def sql_handler(args)
73
- notification = ActiveSupport::Notifications::Event.new *args
74
- connection = if notification.payload[:connection]
75
- notification.payload[:connection]
76
- else
77
- ObjectSpace._id2ref(notification.payload[:connection_id])
78
- end
79
- event = Raygun::Apm::Event::Sql.new
80
- event[:query] = notification.payload[:sql]
81
-
82
- # XXX this is hacky
83
- if config = connection.instance_variable_get('@config')
84
- event[:provider] = config[:adapter]
85
- event[:host] = config[:host]
86
- event[:database] = config[:database]
87
- end
88
-
89
- # XXX constant milliseconds to microseconds
90
- event[:duration] = notification.duration * 1000
91
- event[:timestamp] = notification.time.to_f*1000000
92
- event[:pid] = Process.pid
93
- event[:tid] = @tracer.get_thread_id(Thread.current)
94
- @tracer.emit(event)
95
- rescue => e
96
- # XXX report
97
- end
98
-
99
- def self.finalize(tracer)
100
- proc {tracer.process_ended}
101
- end
102
- end
103
- end
104
- end