Class: Foam::Otel::Instance
- Inherits:
-
Object
- Object
- Foam::Otel::Instance
- Defined in:
- lib/foam/otel/init.rb
Overview
Handle returned by init(). Providers are global — this mostly carries the resolved config and shutdown.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#providers ⇒ Object
Returns the value of attribute providers.
-
#service_name ⇒ Object
readonly
Returns the value of attribute service_name.
Instance Method Summary collapse
-
#initialize(service_name, config) ⇒ Instance
constructor
A new instance of Instance.
- #shutdown ⇒ Object
Constructor Details
#initialize(service_name, config) ⇒ Instance
Returns a new instance of Instance.
23 24 25 26 27 |
# File 'lib/foam/otel/init.rb', line 23 def initialize(service_name, config) @service_name = service_name @config = config @providers = [] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
20 21 22 |
# File 'lib/foam/otel/init.rb', line 20 def config @config end |
#providers ⇒ Object
Returns the value of attribute providers.
21 22 23 |
# File 'lib/foam/otel/init.rb', line 21 def providers @providers end |
#service_name ⇒ Object (readonly)
Returns the value of attribute service_name.
20 21 22 |
# File 'lib/foam/otel/init.rb', line 20 def service_name @service_name end |
Instance Method Details
#shutdown ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/foam/otel/init.rb', line 29 def shutdown if @providers.empty? # This instance owns no providers (inert, or a later init whose # signals were already wired). It must not tear down the owner's # pipelines, but — flush parity — it still best-effort flushes # foam's live pipelines so buffered telemetry isn't dropped. Foam::Otel.flush_foam_pipelines return end @providers.each do |provider| begin provider.shutdown rescue StandardError nil end Foam::Otel.forget_provider(provider) end Foam::Otel.clear_fallback_meter_provider_if_in(@providers) @providers = [] end |