diff --git a/config/initializers/opentelemetry.rb b/config/initializers/opentelemetry.rb index 783f8b37..f1f1ee64 100644 --- a/config/initializers/opentelemetry.rb +++ b/config/initializers/opentelemetry.rb @@ -32,6 +32,10 @@ endpoint: otel_config[:traces_endpoint] ) + # we configure the exporter ourselves + ENV['OTEL_LOGS_EXPORTER'] = 'none' + ENV['OTEL_METRICS_EXPORTER'] = 'none' + OpenTelemetry::SDK.configure do |c| c.resource = otel_resource c.add_span_processor( diff --git a/lib/sagittarius/configuration.rb b/lib/sagittarius/configuration.rb index d1ba0fda..30da7dd6 100644 --- a/lib/sagittarius/configuration.rb +++ b/lib/sagittarius/configuration.rb @@ -10,7 +10,7 @@ def self.config memoize(:config) do configured_files = ENV.fetch(CONFIG_FILES_ENV, nil) config_files(configured_files).reduce(defaults) do |config, config_file| - file_config = YAML.safe_load_file(config_file).deep_symbolize_keys + file_config = YAML.safe_load_file(config_file, fallback: {}).deep_symbolize_keys config.deep_merge(file_config) end rescue Errno::ENOENT diff --git a/spec/lib/sagittarius/configuration_spec.rb b/spec/lib/sagittarius/configuration_spec.rb index 654ed718..9254c7df 100644 --- a/spec/lib/sagittarius/configuration_spec.rb +++ b/spec/lib/sagittarius/configuration_spec.rb @@ -13,7 +13,7 @@ end it 'loads the default config file' do - allow(YAML).to receive(:safe_load_file).with(default_config_file).and_return( + allow(YAML).to receive(:safe_load_file).with(default_config_file, fallback: {}).and_return( 'rails' => { 'web' => { 'threads' => 4 }, 'grpc' => { 'threads' => 8 }, @@ -29,7 +29,7 @@ end it 'uses built-in defaults when the default config file does not exist' do - allow(YAML).to receive(:safe_load_file).with(default_config_file).and_raise(Errno::ENOENT) + allow(YAML).to receive(:safe_load_file).with(default_config_file, fallback: {}).and_raise(Errno::ENOENT) expect(described_class.config).to eq(described_class.defaults) end @@ -39,19 +39,19 @@ configured_files = ' config/base.yml,config/environment.yml, config/runtime.yml ' allow(ENV).to receive(:fetch).with('SAGITTARIUS_CONFIG_FILES', nil) .and_return(configured_files) - allow(YAML).to receive(:safe_load_file).with('config/base.yml').and_return( + allow(YAML).to receive(:safe_load_file).with('config/base.yml', fallback: {}).and_return( 'rails' => { 'web' => { 'threads' => 4, 'port' => 4000 }, 'grpc' => { 'threads' => 4 }, } ) - allow(YAML).to receive(:safe_load_file).with('config/environment.yml').and_return( + allow(YAML).to receive(:safe_load_file).with('config/environment.yml', fallback: {}).and_return( 'rails' => { 'web' => { 'threads' => 8 }, 'grpc' => { 'host' => 'environment:50051' }, } ) - allow(YAML).to receive(:safe_load_file).with('config/runtime.yml').and_return( + allow(YAML).to receive(:safe_load_file).with('config/runtime.yml', fallback: {}).and_return( 'rails' => { 'web' => { 'threads' => 16 }, } @@ -70,13 +70,13 @@ it 'loads each configured file in order' do described_class.config - expect(YAML).to have_received(:safe_load_file).ordered.with('config/base.yml') - expect(YAML).to have_received(:safe_load_file).ordered.with('config/environment.yml') - expect(YAML).to have_received(:safe_load_file).ordered.with('config/runtime.yml') + expect(YAML).to have_received(:safe_load_file).ordered.with('config/base.yml', fallback: {}) + expect(YAML).to have_received(:safe_load_file).ordered.with('config/environment.yml', fallback: {}) + expect(YAML).to have_received(:safe_load_file).ordered.with('config/runtime.yml', fallback: {}) end it 'raises when a configured file does not exist' do - allow(YAML).to receive(:safe_load_file).with('config/environment.yml').and_raise(Errno::ENOENT) + allow(YAML).to receive(:safe_load_file).with('config/environment.yml', fallback: {}).and_raise(Errno::ENOENT) expect { described_class.config }.to raise_error(Errno::ENOENT) end @@ -85,7 +85,10 @@ describe '.defaults' do it 'matches the example config' do - example_config = YAML.safe_load_file(Rails.root.join('config/sagittarius.example.yml')).deep_symbolize_keys + example_config = YAML.safe_load_file( + Rails.root.join('config/sagittarius.example.yml'), + fallback: {} + ).deep_symbolize_keys expect(example_config).to eq(described_class.defaults) end end