Class: Foam::Otel::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/foam/otel/instance.rb

Overview

The handle init() returns. Providers are process-global; this mostly carries the resolved config and orchestrates shutdown/flush. An inert init (enabled: false, or a claimed-all process) owns no providers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Instance

Returns a new instance of Instance.



12
13
14
15
# File 'lib/foam/otel/instance.rb', line 12

def initialize(config)
  @config = config
  @providers = []
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/foam/otel/instance.rb', line 9

def config
  @config
end

#providersObject

Returns the value of attribute providers.



10
11
12
# File 'lib/foam/otel/instance.rb', line 10

def providers
  @providers
end

Instance Method Details

#flushObject

Flush foam's buffered pipelines (delegates to the module-level flush, which knows every foam-owned flushable). Never raises.



21
22
23
# File 'lib/foam/otel/instance.rb', line 21

def flush
  Foam::Otel.flush
end

#nameObject



17
# File 'lib/foam/otel/instance.rb', line 17

def name = @config.name

#shutdownObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/foam/otel/instance.rb', line 25

def shutdown
  if @providers.empty?
    Foam::Otel.flush
    return
  end
  @providers.each do |provider|
    begin
      provider.shutdown
    rescue StandardError, SystemStackError
      # SystemStackError is not a StandardError; a poisoned payload deep
      # in a pipeline must never escape through the at_exit hook into
      # the customer's process teardown (rule 9).
      nil
    end
    Foam::Otel.send(:forget_provider, provider)
  end
  @providers = []
end