-
Notifications
You must be signed in to change notification settings - Fork 369
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
[concurrent_ruby] Propagate active context into span Future whose execution is being deferred. #496
Conversation
b2a50cb
to
a12ecc6
Compare
@delner can you review this PR ? |
Bumping this to 0.15.0. |
@pawelchcki Can you resolve the merge conflict with the GettingStarted.md? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall so far, looking good. Just some general questions so I can understand it a bit better.
register_as :concurrent_ruby | ||
|
||
def self.compatible? | ||
defined?(::Concurrent::Future) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it compatible with Ruby 1.9-2.5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@composited_executor = composited_executor | ||
end | ||
|
||
def post(*args, &task) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain a little about what this function does? Its purpose? Presumably in the context of Concurrent Ruby?
|
||
subject(:deferred_execution) do | ||
outer_span = tracer.trace('outer_span') | ||
inner_span = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious; why does this need to be set to nil
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be able to set the variable in the Closure below and make it accessible outside
|
||
around do |example| | ||
unmodified = ::Concurrent::Future.dup | ||
Datadog.registry[:concurrent_ruby].patcher.instance_variable_set(:@done_once, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how you might want to redo patching when testing patching. However, does this need to be at the outermost level? Can this unpatching be done only in the patching
context? Generally speaking we want to avoid hacking our patching like this, so limiting its footprint to only where its absolutely necessary would be best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to revert this change as all tests required the Future to be in known state as otherwise it would fail based on the order on execution
Resolved the conflicts and address the code review suggestions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Implementation of Context passing to Future execution
Concurrent Ruby
The Concurrent Ruby integration adds support for context propagation when using
::Concurrent::Future
.Making sure that code traced within the
Future#execute
will have correct parent set.To activate your integration, use the
Datadog.configure
method:The
use :concurrent_ruby
method accepts the following parameters:tracer
Datadog::Tracer
instance used to instrument the application. Usually you don't need to set that.Datadog.tracer