Class: DatadogExporter::Client::Config
- Inherits:
-
Object
- Object
- DatadogExporter::Client::Config
- Defined in:
- lib/datadog_exporter/client/config.rb
Overview
The configuration for the DatadogExporter::Client.
Constant Summary collapse
- DEFAULT_ORGANIZATIONS_CONFIGURATIONS =
{ monitors: { export_tag: "", template_keys: [], placeholders: { base: { }, }, }, }.freeze
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #base_path ⇒ Object
-
#datadog_api_configuration ⇒ Object
Creates the Datadog API global configuration.
-
#initialize(**options) ⇒ Config
constructor
NOTE: See DatadogExporter::Configurations to see the available options.
- #organizations_config ⇒ Object
Constructor Details
#initialize(**options) ⇒ Config
NOTE: See DatadogExporter::Configurations to see the available options
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/datadog_exporter/client/config.rb', line 22 def initialize(**) # rubocop:disable Metrics/AbcSize @site = [:site] || DatadogExporter.configuration.site @api_key = [:api_key] || DatadogExporter.configuration.api_key @application_key = [:application_key] || DatadogExporter.configuration.application_key @logger = [:logger] || DatadogExporter.configuration.logger @base_path = [:base_path] || DatadogExporter.configuration.base_path @organizations_config_filename = [:org_config_filename] || DatadogExporter.configuration.organizations_config_filename end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
19 20 21 |
# File 'lib/datadog_exporter/client/config.rb', line 19 def logger @logger end |
Instance Method Details
#base_path ⇒ Object
34 35 36 |
# File 'lib/datadog_exporter/client/config.rb', line 34 def base_path Pathname.new(@base_path) end |
#datadog_api_configuration ⇒ Object
Creates the Datadog API global configuration
See github.com/DataDog/datadog-api-client-ruby/blob/master/lib/datadog_api_client/configuration.rb
41 42 43 44 45 46 47 |
# File 'lib/datadog_exporter/client/config.rb', line 41 def datadog_api_configuration DatadogAPIClient::Configuration.new do |client_config| client_config.server_variables[:site] = @site client_config.api_key = @api_key client_config.application_key = @application_key end end |
#organizations_config ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/datadog_exporter/client/config.rb', line 49 def organizations_config organizations_config_file = base_path.join(@organizations_config_filename) unless File.exist?(organizations_config_file) warn( "WARNING: Organizations configuration file not found: #{organizations_config_file}. Using default configuration.", ) return DEFAULT_ORGANIZATIONS_CONFIGURATIONS end DEFAULT_ORGANIZATIONS_CONFIGURATIONS.merge(YAML.load_file(organizations_config_file)) end |