Class: Appsignal::Config
- Defined in:
- lib/appsignal/config.rb,
sig/appsignal.rbs
Defined Under Namespace
Classes: ConfigDSL
Instance Method Summary collapse
-
#active? ⇒ Boolean
Check if AppSignal is active.
-
#active_for_env? ⇒ Boolean
Check if AppSignal is active for the current environment.
-
#collector_mode? ⇒ Boolean
Check if AppSignal is actively running in collector mode.
-
#collector_mode_configured? ⇒ Boolean
Check if collector mode is configured.
-
#valid? ⇒ Boolean
Check if the configuration is valid.
- #yml_config_file? ⇒ Boolean private
Instance Method Details
#active? ⇒ Boolean
Check if AppSignal is active.
@return — True if valid and active for the current environment.
504 505 506 |
# File 'lib/appsignal/config.rb', line 504 def active? valid? && active_for_env? end |
#active_for_env? ⇒ Boolean
Check if AppSignal is active for the current environment.
@return — True if active for the current environment.
497 498 499 |
# File 'lib/appsignal/config.rb', line 497 def active_for_env? config_hash[:active] end |
#collector_mode? ⇒ Boolean
Check if AppSignal is actively running in collector mode.
True only if collector mode is configured
and Appsignal::OpenTelemetry.configure has successfully booted the
SDK in this process. Use this for backend dispatch on hot paths
(metric and log emits): if the OTel boot failed, callers fall back to
the agent backend rather than silently dropping data into no-op
providers.
@return — True if collector mode is configured and started.
553 554 555 556 557 |
# File 'lib/appsignal/config.rb', line 553 def collector_mode? collector_mode_configured? && defined?(Appsignal::OpenTelemetry) && Appsignal::OpenTelemetry.started? end |
#collector_mode_configured? ⇒ Boolean
Check if collector mode is configured.
Returns true when a non-empty collector_endpoint is set and the
running Ruby version is at least MIN_RUBY_VERSION_FOR_COLLECTOR_MODE.
On older Rubies, collector_endpoint is ignored (with a warning) and
the AppSignal agent is used instead.
This is the intent check — it answers "did the user ask for collector mode, and could we honor it?". It does not say whether the OpenTelemetry SDK actually booted. See #collector_mode? for that.
Memoised: the result is cached on first call so hot paths avoid
re-running the string-strip predicate, and so the unsupported-Ruby
warning is emitted at most once per Config instance.
@return — True if collector mode is configured.
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
# File 'lib/appsignal/config.rb', line 524 def collector_mode_configured? return @collector_mode_configured if defined?(@collector_mode_configured) endpoint = config_hash[:collector_endpoint] configured = !endpoint.nil? && !endpoint.to_s.strip.empty? if configured && Gem::Version.new(RUBY_VERSION) < Gem::Version.new(MIN_RUBY_VERSION_FOR_COLLECTOR_MODE) Appsignal::Utils::StdoutAndLoggerMessage.warning( "Collector mode requires Ruby #{MIN_RUBY_VERSION_FOR_COLLECTOR_MODE} or higher " \ "(running Ruby #{RUBY_VERSION}). The `collector_endpoint` option will be " \ "ignored and the AppSignal agent will be used instead." ) @collector_mode_configured = false else @collector_mode_configured = configured end end |
#valid? ⇒ Boolean
Check if the configuration is valid.
@return — True if the configuration is valid, false otherwise.
490 491 492 |
# File 'lib/appsignal/config.rb', line 490 def valid? @valid end |
#yml_config_file? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
674 675 676 677 678 |
# File 'lib/appsignal/config.rb', line 674 def yml_config_file? return false unless yml_config_file File.exist?(yml_config_file) end |