Skip to content

Commit f8ae3b3

Browse files
committed
DEBUG-3457 hack probe notifier worker starting
1 parent fba70fd commit f8ae3b3

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

lib/datadog/di/component.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,18 @@ def initialize(settings, agent_settings, logger, code_tracker: nil, telemetry: n
8484
@probe_notifier_worker = ProbeNotifierWorker.new(settings, transport, logger, telemetry: telemetry)
8585
@probe_notification_builder = ProbeNotificationBuilder.new(settings, serializer)
8686
@probe_manager = ProbeManager.new(settings, instrumenter, probe_notification_builder, probe_notifier_worker, logger, telemetry: telemetry)
87-
probe_notifier_worker.start
87+
88+
# If the worker is started here, it will be in the parent process
89+
# of forking web servers like puma rather than in the worker processes
90+
# that actually process HTTP requests, and thus DI will end up not
91+
# sending any events to the agent.
92+
#
93+
# There is currently no "nice" way to handle this situation correctly -
94+
# remote config has the same issue and the tracing Rack middleware
95+
# presently starts the remote config worker.
96+
#
97+
# DI is hacked into that middleware the same way.
98+
#probe_notifier_worker.start
8899
end
89100

90101
attr_reader :settings

lib/datadog/tracing/contrib/rack/middlewares.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def call(env)
3939

4040
boot = Datadog::Core::Remote::Tie.boot
4141

42+
if defined?(Datadog::DI)
43+
Datadog::DI.current_component&.probe_notifier_worker&.start
44+
end
45+
4246
# Extract distributed tracing context before creating any spans,
4347
# so that all spans will be added to the distributed trace.
4448
if configuration[:distributed_tracing]

spec/datadog/di/integration/everything_from_remote_config_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def target_method
106106

107107
before do
108108
expect(Datadog::DI).to receive(:component).at_least(:once).and_return(component)
109+
110+
# This is done by tracing Rack middleware in actual applications
111+
component.probe_notifier_worker.start
109112
end
110113

111114
let(:mock_response) do

spec/datadog/di/integration/instrumentation_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ def mutating_method(greeting)
107107
allow(agent_settings).to receive(:ssl)
108108

109109
allow(Datadog::DI).to receive(:current_component).and_return(component)
110+
111+
# This is done by tracing Rack middleware in actual applications
112+
component.probe_notifier_worker.start
110113
end
111114

112115
context 'method probe' do

0 commit comments

Comments
 (0)