Skip to content

Commit

Permalink
Include loader and DSL source in diagnose report (#1235)
Browse files Browse the repository at this point in the history
Show all sources for config in the diagnose report. I didn't add this in
the PRs that added the loaders and DSL config, because no part of the
diagnose command would load code that can modify these sources. Now I'm
working on loading a Rails app in the diagnose command, so it's good to
include these sources for when we also want to include the config from
the Rails app.
  • Loading branch information
tombruijn authored Aug 7, 2024
1 parent 03779ed commit a7b3411
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: change
---

Include the config options from the loaders config defaults and the `Appsignal.configure` helper in diagnose report. The sources for config option values will include the loaders and `Appsignal.configure` helper in the output and the JSON report sent to our severs, when opted-in.
4 changes: 3 additions & 1 deletion lib/appsignal/cli/diagnose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,12 @@ def print_config_section
:sources => {
:default => Appsignal::Config::DEFAULT_CONFIG,
:system => config.system_config,
:loaders => config.loaders_config,
:initial => config.initial_config,
:file => config.file_config,
:env => config.env_config,
:override => config.override_config
:override => config.override_config,
:dsl => config.dsl_config
}
}
print_config_options(config)
Expand Down
9 changes: 7 additions & 2 deletions lib/appsignal/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def self.determine_root_path

# @api private
attr_accessor :root_path, :env, :config_hash
attr_reader :system_config, :initial_config, :file_config, :env_config,
:override_config, :dsl_config
attr_reader :system_config, :loaders_config, :initial_config, :file_config,
:env_config, :override_config, :dsl_config
# @api private
attr_accessor :logger

Expand Down Expand Up @@ -249,6 +249,7 @@ def initialize( # rubocop:disable Metrics/ParameterLists
@env = initial_env.to_s
@config_hash = {}
@system_config = {}
@loaders_config = {}
@initial_config = initial_config
@file_config = {}
@env_config = {}
Expand Down Expand Up @@ -279,6 +280,10 @@ def load_config
# loader's defaults overwrite all others
self.class.loader_defaults.reverse.each do |loader_defaults|
defaults = loader_defaults[:options]
@loaders_config.merge!(defaults.merge(
:root_path => loader_defaults[:root_path],
:env => loader_defaults[:env]
))
merge(defaults)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/diagnose
12 changes: 9 additions & 3 deletions spec/lib/appsignal/cli/diagnose_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,12 @@ def dont_accept_prompt_to_send_diagnostics_report
"sources" => {
"default" => default_config,
"system" => {},
"loaders" => {},
"initial" => { "env" => "" },
"file" => {},
"env" => {},
"override" => {}
"override" => {},
"dsl" => {}
}
)
end
Expand Down Expand Up @@ -954,10 +956,12 @@ def dont_accept_prompt_to_send_diagnostics_report
"sources" => {
"default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
"system" => {},
"loaders" => {},
"initial" => hash_with_string_keys(Appsignal.config.initial_config),
"file" => hash_with_string_keys(Appsignal.config.file_config),
"env" => {},
"override" => {}
"override" => {},
"dsl" => {}
}
)
end
Expand Down Expand Up @@ -986,10 +990,12 @@ def dont_accept_prompt_to_send_diagnostics_report
"sources" => {
"default" => hash_with_string_keys(Appsignal::Config::DEFAULT_CONFIG),
"system" => {},
"loaders" => {},
"initial" => hash_with_string_keys(Appsignal.config.initial_config),
"file" => hash_with_string_keys(Appsignal.config.file_config),
"env" => {},
"override" => {}
"override" => {},
"dsl" => {}
}
)
end
Expand Down

0 comments on commit a7b3411

Please sign in to comment.