Class: Datadog::Contrib::ConcurrentRuby::ContextCompositeExecutorService

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Concurrent::ExecutorService
Defined in:
lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb

Overview

wraps existing executor to carry over trace context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(composited_executor) ⇒ ContextCompositeExecutorService

Returns a new instance of ContextCompositeExecutorService.



13
14
15
# File 'lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb', line 13

def initialize(composited_executor)
  @composited_executor = composited_executor
end

Instance Attribute Details

#composited_executorObject

Returns the value of attribute composited_executor.



11
12
13
# File 'lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb', line 11

def composited_executor
  @composited_executor
end

Instance Method Details

#datadog_configurationObject



27
28
29
# File 'lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb', line 27

def datadog_configuration
  Datadog.configuration[:concurrent_ruby]
end

#post(*args, &task) ⇒ Object

post method runs the task within composited executor - in a different thread



18
19
20
21
22
23
24
25
# File 'lib/ddtrace/contrib/concurrent_ruby/context_composite_executor_service.rb', line 18

def post(*args, &task)
  context = datadog_configuration.tracer.provider.context

  @composited_executor.post(*args) do
    datadog_configuration.tracer.provider.context = context
    yield
  end
end