Skip to content

Commit

Permalink
Merge pull request #3745 from DataDog/anmarchenko/fix_telemetry_threa…
Browse files Browse the repository at this point in the history
…ds_deadlock_backport

fix telemetry threads deadlock backport
  • Loading branch information
anmarchenko committed Jun 28, 2024
2 parents bcc0acf + 5a06b58 commit 7b6ee24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/datadog/core/telemetry/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ def start
def stop(force_stop = false, timeout = @shutdown_timeout)
buffer.close if running?

flush_events(dequeue) if work_pending?

super
end

Expand Down Expand Up @@ -136,6 +134,10 @@ def dequeue
buffer.pop
end

def work_pending?
run_loop? || !buffer.empty?
end

def buffer_klass
if Core::Environment::Ext::RUBY_ENGINE == 'ruby'
Core::Buffer::CRuby
Expand Down
2 changes: 2 additions & 0 deletions spec/datadog/core/telemetry/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@
worker.start

expect(worker).to receive(:flush_events).at_least(:once)

worker.enqueue(Datadog::Core::Telemetry::Event::AppIntegrationsChange.new)
worker.stop(true)
end
end
Expand Down

0 comments on commit 7b6ee24

Please sign in to comment.