Module: Datadog::Tracing::Contrib::Sidekiq::Patcher
- Includes:
- Patcher
- Defined in:
- lib/datadog/tracing/contrib/sidekiq/patcher.rb
Overview
Patcher enables patching of ‘sidekiq’ module.
Class Method Summary collapse
- .patch ⇒ Object
- .patch_redis_info ⇒ Object
- .patch_server_heartbeat ⇒ Object
- .patch_server_internals ⇒ Object
- .patch_server_job_fetch ⇒ Object
- .patch_server_scheduled_push ⇒ Object
- .target_version ⇒ Object
Methods included from Patcher
Class Method Details
.patch ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/datadog/tracing/contrib/sidekiq/patcher.rb', line 19 def patch require_relative 'client_tracer' require_relative 'server_tracer' ::Sidekiq.configure_client do |config| config.client_middleware do |chain| chain.add(Sidekiq::ClientTracer) end end ::Sidekiq.configure_server do |config| # If a job enqueues another job, make sure it has the same client # middleware. config.client_middleware do |chain| chain.add(Sidekiq::ClientTracer) end config.server_middleware do |chain| chain.add(Sidekiq::ServerTracer) end patch_server_internals if Integration.compatible_with_server_internal_tracing? end end |
.patch_redis_info ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/datadog/tracing/contrib/sidekiq/patcher.rb', line 77 def patch_redis_info require_relative 'server_internal_tracer/redis_info' if Integration.supports_capsules? ::Sidekiq::Config.prepend(ServerInternalTracer::RedisInfo) else ::Sidekiq.singleton_class.prepend(ServerInternalTracer::RedisInfo) end end |
.patch_server_heartbeat ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/datadog/tracing/contrib/sidekiq/patcher.rb', line 51 def patch_server_heartbeat require_relative 'server_internal_tracer/stop' require_relative 'server_internal_tracer/heartbeat' ::Sidekiq::Launcher.prepend(ServerInternalTracer::Stop) # Sidekiq 7 changed method `heartbeat` to `beat` if ::Sidekiq::Launcher.private_method_defined? :heartbeat ::Sidekiq::Launcher.prepend(ServerInternalTracer::Heartbeat) end ::Sidekiq::Launcher.prepend(ServerInternalTracer::Beat) if ::Sidekiq::Launcher.private_method_defined? :beat end |
.patch_server_internals ⇒ Object
44 45 46 47 48 49 |
# File 'lib/datadog/tracing/contrib/sidekiq/patcher.rb', line 44 def patch_server_internals patch_server_heartbeat patch_server_job_fetch patch_server_scheduled_push patch_redis_info end |
.patch_server_job_fetch ⇒ Object
65 66 67 68 69 |
# File 'lib/datadog/tracing/contrib/sidekiq/patcher.rb', line 65 def patch_server_job_fetch require_relative 'server_internal_tracer/job_fetch' ::Sidekiq::Processor.prepend(ServerInternalTracer::JobFetch) end |
.patch_server_scheduled_push ⇒ Object
71 72 73 74 75 |
# File 'lib/datadog/tracing/contrib/sidekiq/patcher.rb', line 71 def patch_server_scheduled_push require_relative 'server_internal_tracer/scheduled_poller' ::Sidekiq::Scheduled::Poller.prepend(ServerInternalTracer::ScheduledPoller) end |
.target_version ⇒ Object
15 16 17 |
# File 'lib/datadog/tracing/contrib/sidekiq/patcher.rb', line 15 def target_version Integration.version end |