Skip to content

Commit 6b654d4

Browse files
committed
Fix karafka framework patch
1 parent ba11317 commit 6b654d4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/datadog/tracing/contrib/karafka/patcher.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ def each(&block)
4848
end
4949
end
5050

51+
module AppPatch
52+
ONLY_ONCE_PER_APP = Hash.new { |h, key| h[key] = Core::Utils::OnlyOnce.new }
53+
54+
def initialized!
55+
ONLY_ONCE_PER_APP[self].run do
56+
# Activate tracing on components related to Karafka (e.g. WaterDrop)
57+
Contrib::Karafka::Framework.setup
58+
end
59+
super
60+
end
61+
end
62+
5163
# Patcher enables patching of 'karafka' module.
5264
module Patcher
5365
include Contrib::Patcher
@@ -60,12 +72,11 @@ def target_version
6072

6173
def patch
6274
require_relative 'monitor'
75+
require_relative 'framework'
6376

6477
::Karafka::Instrumentation::Monitor.prepend(Monitor)
6578
::Karafka::Messages::Messages.prepend(MessagesPatch)
66-
67-
# Activate tracing on components related to Karafka (e.g. WaterDrop)
68-
Framework.setup
79+
::Karafka::App.singleton_class.prepend(AppPatch)
6980
end
7081
end
7182
end

0 commit comments

Comments
 (0)