Closed
Description
openedon May 8, 2018
We have a few places in our application with multiple independent slow ActiveRecord queries that we use concurrent-ruby's Concurrent::Future class to parallelize, then block on the combined results. Here's some pseudo-code
scope = MyModel.slow_sql_query
# Start both queries in parallel
future_a_1 = Concurrent::Future.execute { scope.where(a: 1).to_a }
future_a_2 = Concurrent::Future.execute { scope.where(a: 2).to_a }
# Blocks, ensuring we don't attempt to render before the queries are complete
@a_1 = future_a_1.value
@a_2 = future_a_2.value
render :show
To my surprise, the traces of the queries executed in the Future don't appear in DD. I'm assuming this has something to do with the trace ID being stored in Thread.current
, or the Future threads in some other way being unaware of the trace ID.
What can I do to ensure these query spans are included in my trace?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment