Class: OpenTelemetry::Instrumentation::ConcurrentRuby::ContextCompositeExecutorService

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Concurrent::ExecutorService
Defined in:
lib/opentelemetry/instrumentation/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.



20
21
22
# File 'lib/opentelemetry/instrumentation/concurrent_ruby/context_composite_executor_service.rb', line 20

def initialize(composited_executor)
  @composited_executor = composited_executor
end

Instance Attribute Details

#composited_executorObject

Returns the value of attribute composited_executor.



18
19
20
# File 'lib/opentelemetry/instrumentation/concurrent_ruby/context_composite_executor_service.rb', line 18

def composited_executor
  @composited_executor
end

Instance Method Details

#post(*args, &task) ⇒ Object

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



26
27
28
29
30
31
32
33
34
# File 'lib/opentelemetry/instrumentation/concurrent_ruby/context_composite_executor_service.rb', line 26

def post(*args, &task)
  context = OpenTelemetry::Context.current

  @composited_executor.post(*args) do
    OpenTelemetry::Context.with_current(context) do
      yield
    end
  end
end