Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[resque] Shutdown tracer and flush data on job finish instead of using SyncWriter. #474

Merged
merged 2 commits into from
Jul 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions lib/ddtrace/contrib/resque/resque_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,18 @@ def around_perform(*args)
yield
span.service = pin.service
end
ensure
pin.tracer.shutdown! if pin && pin.tracer
end
end
end
end
end

Resque.before_first_fork do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure of that change? I remember we added it to handle some cases. We need to deeply test those changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to ship it first as a beta release and before that do another round of testing.

I've tested this change locally when developing it and coupled with some other improvements in separate PRs, it did flush and shutdown as quickly as SyncWriter.

This change is mostly driven by the fact that SyncWriter performance deteriorates quite a bit under multithreaded setup.

pin = Datadog::Pin.get_from(Resque)
next unless pin && pin.tracer

# Create SyncWriter instance before forking
sync_writer = Datadog::SyncWriter.new(transport: pin.tracer.writer.transport)
Datadog::Contrib::Resque.sync_writer = sync_writer
end

Resque.after_fork do
# get the current tracer
pin = Datadog::Pin.get_from(Resque)
next unless pin && pin.tracer
# clean the state so no CoW happens
pin.tracer.provider.context = nil
pin.tracer.writer = Datadog::Contrib::Resque.sync_writer
end