diff --git a/async.gemspec b/async.gemspec index 5fe97df..378ae42 100644 --- a/async.gemspec +++ b/async.gemspec @@ -27,5 +27,7 @@ Gem::Specification.new do |spec| spec.add_dependency "console", "~> 1.29" spec.add_dependency "fiber-annotation" - spec.add_dependency "io-event", ["~> 1.6", ">= 1.6.5"] + spec.add_dependency "io-event", "~> 1.7" + spec.add_dependency "traces", "~> 0.15" + spec.add_dependency "metrics", "~> 0.12" end diff --git a/gems.rb b/gems.rb index dc5cf78..e506ace 100644 --- a/gems.rb +++ b/gems.rb @@ -25,9 +25,6 @@ gem "decode" gem "rubocop" - gem "traces" - gem "metrics" - gem "sus-fixtures-async" gem "sus-fixtures-console" gem "sus-fixtures-time" diff --git a/lib/traces/provider/async/task.rb b/lib/traces/provider/async/task.rb index 8867ed7..c7c5fd5 100644 --- a/lib/traces/provider/async/task.rb +++ b/lib/traces/provider/async/task.rb @@ -8,6 +8,11 @@ Traces::Provider(Async::Task) do def schedule(&block) + # If we are not actively tracing anything, then we can skip this: + unless Traces.active? + return super(&block) + end + unless self.transient? trace_context = Traces.trace_context end @@ -18,6 +23,7 @@ def schedule(&block) "transient" => self.transient?, } + # Run the trace in the context of the child task: super do Traces.trace_context = trace_context @@ -26,6 +32,7 @@ def schedule(&block) end Traces.trace("async.task", attributes: attributes) do + # Yes, this is correct, we already called super above: yield end end