Class: MysqlFramework::Stats::DimensionMap
- Inherits:
-
Object
- Object
- MysqlFramework::Stats::DimensionMap
- Defined in:
- lib/mysql_framework/stats/dimension_map.rb
Overview
Class to handle dimensions for AWS reporting
Instance Attribute Summary collapse
-
#application ⇒ Object
Returns the value of attribute application.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#landscape ⇒ Object
Returns the value of attribute landscape.
-
#namespace ⇒ String
Returns the CloudWatch namespace.
-
#service_name ⇒ Object
Returns the value of attribute service_name.
Instance Method Summary collapse
-
#initialize(service_name: nil, application: nil, environment: nil, landscape: nil, namespace: nil) ⇒ void
constructor
Initializes dimension values used for CloudWatch metrics.
-
#to_cloudwatch_dimensions ⇒ Array<Hash{Symbol => String}>
Builds CloudWatch dimensions from configured values or environment variables.
Constructor Details
#initialize(service_name: nil, application: nil, environment: nil, landscape: nil, namespace: nil) ⇒ void
Initializes dimension values used for CloudWatch metrics.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mysql_framework/stats/dimension_map.rb', line 17 def initialize( service_name: nil, application: nil, environment: nil, landscape: nil, namespace: nil ) @service_name = service_name @application = application @environment = environment @landscape = landscape @namespace = namespace end |
Instance Attribute Details
#application ⇒ Object
Returns the value of attribute application.
7 8 9 |
# File 'lib/mysql_framework/stats/dimension_map.rb', line 7 def application @application end |
#environment ⇒ Object
Returns the value of attribute environment.
7 8 9 |
# File 'lib/mysql_framework/stats/dimension_map.rb', line 7 def environment @environment end |
#landscape ⇒ Object
Returns the value of attribute landscape.
7 8 9 |
# File 'lib/mysql_framework/stats/dimension_map.rb', line 7 def landscape @landscape end |
#namespace ⇒ String
Returns the CloudWatch namespace.
46 47 48 |
# File 'lib/mysql_framework/stats/dimension_map.rb', line 46 def namespace @namespace end |
#service_name ⇒ Object
Returns the value of attribute service_name.
7 8 9 |
# File 'lib/mysql_framework/stats/dimension_map.rb', line 7 def service_name @service_name end |
Instance Method Details
#to_cloudwatch_dimensions ⇒ Array<Hash{Symbol => String}>
Builds CloudWatch dimensions from configured values or environment variables.
34 35 36 37 38 39 40 41 |
# File 'lib/mysql_framework/stats/dimension_map.rb', line 34 def to_cloudwatch_dimensions [ { name: 'ServiceName', value: service_name || ENV.fetch('SERVICE_NAME', nil) }, { name: 'Application', value: application || ENV.fetch('APPLICATION', nil) }, { name: 'Environment', value: environment || ENV.fetch('ENVIRONMENT', nil) }, { name: 'Landscape', value: landscape || ENV.fetch('LANDSCAPE', nil) } ].reject { |dimension| dimension[:value].nil? } end |