raygun-apm-sidekiq 1.1.2 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 983d18c44dad05861403a92a3bdea42df25f39e312cd4a441137a2cdee76c1f2
4
- data.tar.gz: 8f706e3487836cd6a8953f5c6c8fa436fafba79ff9297ede0af20d85db9c6b95
3
+ metadata.gz: c5fc6b9bda748d50bb29765022b36871e2f19496e33d7514db0ac9b77413b309
4
+ data.tar.gz: c068cf98e27b072454263dbe9397d388ef6e6793daa3d744de780e7463a8f5da
5
5
  SHA512:
6
- metadata.gz: 1e5822a24b86b23059fceb1c8053f47b218f35cef606cf748b6eb747a98ad55f6c684292912bd72e51e9165d5ae6334637e94f335d5dec860814d354edbb1140
7
- data.tar.gz: f59cd1281bea3d057668cf710576438e5f8f17ac3621b646521534430bd81ba1d1d9d85a84ca87886a5a347f73772b5c4eb53d9b62b2fe9ce48831a023c0e12a
6
+ metadata.gz: f5c0d359d0c962459877623398dd7be3de36998f84bdbff8a06ed2cb5e5a9c7f0ee25e8079696a6a7d9d05fbc0ac48df464dd22d1a6a0beba39da3757038f5cc
7
+ data.tar.gz: c4da6201e7bfbdca63853292c1cf7d13d1c41a274d1073fdeeaea232236fc723bf2c323101e6bdfa8358d33a389b82294ed9cf0a51b6fc0421ef1cd98658e30c
@@ -4,35 +4,32 @@ require 'sidekiq/processor'
4
4
  module Raygun
5
5
  module Apm
6
6
  module Sidekiq
7
- module Hook
7
+ class Middleware
8
8
  def self.finalize(tracer)
9
9
  proc {tracer.process_ended}
10
10
  end
11
11
 
12
12
  def initialize(*args)
13
- super
14
- @mutex = Mutex.new
15
- @mutex.synchronize do
13
+ Raygun::Apm::Tracer.synchronize do
16
14
  @tracer = Raygun::Apm::Tracer.instance || init_tracer
17
15
  end
18
16
  end
19
17
 
20
- def process(work)
21
- job_hash = ::Sidekiq.load_json(work.job)
22
- queue = work.queue_name
18
+ def call(worker, job_hash, queue)
23
19
  # Can be nil if we had a fatal error
20
+ worker_started = nil
24
21
  if @tracer
25
- @worker_started = @tracer.now
22
+ worker_started = @tracer.now
26
23
  @tracer.start_trace
27
24
  end
28
25
  exception = nil
29
26
  Ruby_APM_profiler_trace do
30
27
  begin
31
- super
32
- fake_http_in_handler(@tracer, @worker_started, job_hash, queue, nil) if @tracer
28
+ yield
29
+ fake_http_in_handler(@tracer, worker_started, job_hash, queue, nil) if @tracer
33
30
  rescue => e
34
31
  crash_report_exception(e)
35
- fake_http_in_handler(@tracer, @worker_started, job_hash, queue, e) if @tracer
32
+ fake_http_in_handler(@tracer, worker_started, job_hash, queue, e) if @tracer
36
33
  exception = e
37
34
  end
38
35
  end
@@ -50,8 +47,8 @@ module Raygun
50
47
 
51
48
  def init_tracer
52
49
  tracer = Raygun::Apm::Tracer.new
53
- tracer.udp_sink!
54
- ObjectSpace.define_finalizer(self, Hook.finalize(tracer))
50
+ tracer.enable_sink!
51
+ ObjectSpace.define_finalizer(self, Middleware.finalize(tracer))
55
52
 
56
53
  ActiveSupport::Notifications.unsubscribe(@sql_subscriber) if @sql_subscriber
57
54
  @sql_subscriber = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
@@ -69,6 +66,7 @@ module Raygun
69
66
  warn "[Raygun APM] shutting down due to error - #{exception.message} #{exception.backtrace.join("\n")}"
70
67
  # Kill extended event subcriptions
71
68
  ActiveSupport::Notifications.unsubscribe(@sql_subscriber)
69
+ @sql_subscriber = nil
72
70
  warn "[Raygun APM] notification hooks unsubscribed"
73
71
  # Let the GC clean up the sink thread through the finalizer below
74
72
  @tracer = nil
@@ -93,7 +91,7 @@ module Raygun
93
91
  end
94
92
 
95
93
  def http_in_event
96
- @http_in_event ||= begin
94
+ Thread.current[:_raygun_http_in_event] ||= begin
97
95
  event = Raygun::Apm::Event::HttpIn.new
98
96
  event[:verb] = "POST"
99
97
  event
@@ -129,7 +127,7 @@ module Raygun
129
127
  end
130
128
 
131
129
  def sql_event
132
- @sql_event ||= Raygun::Apm::Event::Sql.new
130
+ Thread.current[:_raygun_sql_event] ||= Raygun::Apm::Event::Sql.new
133
131
  end
134
132
 
135
133
  def Ruby_APM_profiler_trace
@@ -147,4 +145,8 @@ module Raygun
147
145
  end
148
146
  end
149
147
 
150
- Sidekiq::Processor.prepend Raygun::Apm::Sidekiq::Hook
148
+ Sidekiq.configure_server do |config|
149
+ config.server_middleware do |chain|
150
+ chain.add Raygun::Apm::Sidekiq::Middleware
151
+ end
152
+ end
@@ -4,11 +4,8 @@ module Raygun
4
4
  class Railtie < ::Rails::Railtie
5
5
  initializer "raygun.apm.sidekiq" do |app|
6
6
  require "raygun/apm"
7
- require "raygun/apm/sidekiq/hook"
7
+ require "raygun/apm/sidekiq/middleware"
8
8
  Raygun::Apm::Blacklist.extend_with Raygun::Apm::Sidekiq::BLACKLIST
9
- # Explictly enable instrumenting HTTP until a good control API is figured out
10
- require "raygun/apm/hooks/net_http"
11
- require "raygun/apm/hooks/redis" if defined?(Redis::Client)
12
9
  # Attempt to explicitly require the raygun4ruby sidekiq integration
13
10
  begin
14
11
  require "raygun/sidekiq"
@@ -1,7 +1,7 @@
1
1
  module Raygun
2
2
  module Apm
3
3
  module Sidekiq
4
- VERSION = "1.1.2"
4
+ VERSION = "1.1.5"
5
5
  end
6
6
  end
7
7
  end
@@ -7,7 +7,7 @@ module Raygun
7
7
 
8
8
  BLACKLIST = %w{
9
9
  Sidekiq
10
- +Raygun::Apm::Sidekiq::Hook#Ruby_APM_profiler_trace
10
+ +Raygun::Apm::Sidekiq::Middleware#Ruby_APM_profiler_trace
11
11
  }
12
12
 
13
13
  def self.raygun4ruby?(configured = true)
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "raygun-apm"
21
+ spec.add_dependency "raygun-apm", "~> 1.1.11"
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "minitest", "~> 5.0"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raygun-apm-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raygun Limited
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raygun-apm
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.1.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.1.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -79,7 +79,7 @@ files:
79
79
  - bin/console
80
80
  - bin/setup
81
81
  - lib/raygun/apm/sidekiq.rb
82
- - lib/raygun/apm/sidekiq/hook.rb
82
+ - lib/raygun/apm/sidekiq/middleware.rb
83
83
  - lib/raygun/apm/sidekiq/railtie.rb
84
84
  - lib/raygun/apm/sidekiq/version.rb
85
85
  - raygun-apm-sidekiq.gemspec