lib/fog/aws/cloud_watch.rb in fog-1.6.0 vs lib/fog/aws/cloud_watch.rb in fog-1.7.0
- old
+ new
@@ -4,11 +4,11 @@
module AWS
class CloudWatch < Fog::Service
extend Fog::AWS::CredentialFetcher::ServiceMethods
requires :aws_access_key_id, :aws_secret_access_key
- recognizes :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at
+ recognizes :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
request_path 'fog/aws/requests/cloud_watch'
request :list_metrics
request :get_metric_statistics
@@ -92,10 +92,14 @@
def initialize(options={})
@use_iam_profile = options[:use_iam_profile]
setup_credentials(options)
@connection_options = options[:connection_options] || {}
+
+ @instrumentor = options[:instrumentor]
+ @instrumentor_name = options[:instrumentor_name] || 'fog.aws.cloud_watch'
+
options[:region] ||= 'us-east-1'
@host = options[:host] || "monitoring.#{options[:region]}.amazonaws.com"
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@@ -134,9 +138,19 @@
:port => @port,
:version => '2010-08-01'
}
)
+ if @instrumentor
+ @instrumentor.instrument("#{@instrumentor_name}.request", params) do
+ _request(body, idempotent, parser)
+ end
+ else
+ _request(body, idempotent, parser)
+ end
+ end
+
+ def _request(body, idempotent, parser)
@connection.request({
:body => body,
:expects => 200,
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
:idempotent => idempotent,