lib/pghero/methods/system.rb in pghero-2.8.3 vs lib/pghero/methods/system.rb in pghero-3.0.0

- old
+ new

@@ -3,13 +3,12 @@ module System def system_stats_enabled? !system_stats_provider.nil? end - # TODO remove defined checks in 3.0 def system_stats_provider - if aws_db_instance_identifier && (defined?(Aws) || defined?(AWS)) + if aws_db_instance_identifier :aws elsif gcp_database_id :gcp elsif azure_resource_id :azure @@ -40,21 +39,16 @@ system_stats(:free_space, **options) end def rds_stats(metric_name, duration: nil, period: nil, offset: nil, series: false) if system_stats_enabled? - aws_options = {region: region} - if access_key_id - aws_options[:access_key_id] = access_key_id - aws_options[:secret_access_key] = secret_access_key + aws_options = {region: aws_region} + if aws_access_key_id + aws_options[:access_key_id] = aws_access_key_id + aws_options[:secret_access_key] = aws_secret_access_key end - client = - if defined?(Aws) - Aws::CloudWatch::Client.new(aws_options) - else - AWS::CloudWatch.new(aws_options).client - end + client = Aws::CloudWatch::Client.new(aws_options) duration = (duration || 1.hour).to_i period = (period || 1.minute).to_i offset = (offset || 0).to_i end_time = Time.at(((Time.now - offset).to_f / period).ceil * period)