Class: Aspecto::OpenTelemetry::Config::RemoteConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/aspecto/opentelemetry/config/remote_config.rb

Overview

Handle fetching of remote configuration from aspecto

Instance Method Summary collapse

Constructor Details

#initialize(aspecto_auth, service_name, env, fallback_sampler) ⇒ RemoteConfig

Returns a new instance of RemoteConfig.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/aspecto/opentelemetry/config/remote_config.rb', line 16

def initialize(aspecto_auth, service_name, env, fallback_sampler)
  @service_name = service_name
  @env = env
  @error_reported = false
  @got_remote_config = false
  @fallback_sampler = fallback_sampler
  aspecto_config_host = ENV.fetch("ASPECTO_CONFIG_HOST", "https://config.aspecto.io")
  @aspecto_config_url = URI("#{aspecto_config_host}/config/#{aspecto_auth}")
  init_http_client

  @scheduler = Rufus::Scheduler.new
  @remote_config_poll_frequency = ENV.fetch("ASPECTO_REMOTE_CONFIG_POLL_FREQUENCY", "30s")
  @scheduler.interval @remote_config_poll_frequency, first: :now do
    update_config
  end

  ::OpenTelemetry.logger.info "[Aspecto] initialized remote config polling"
rescue StandardError => e
  ::OpenTelemetry.logger.error "[Aspecto] failed to initialize remote config polling"
  ::OpenTelemetry.logger.error e
end

Instance Method Details

#shutdownObject



38
39
40
# File 'lib/aspecto/opentelemetry/config/remote_config.rb', line 38

def shutdown
  @scheduler.shutdown
end