From 545ba0dd3dca7c8e8f236c47eda0e29de1445695 Mon Sep 17 00:00:00 2001 From: Michael Hale Date: Tue, 16 Oct 2012 09:27:52 -0400 Subject: [PATCH] [aws|cloud_watch] Add instrumentation support. --- lib/fog/aws/cloud_watch.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/fog/aws/cloud_watch.rb b/lib/fog/aws/cloud_watch.rb index b93753416..2bee06678 100644 --- a/lib/fog/aws/cloud_watch.rb +++ b/lib/fog/aws/cloud_watch.rb @@ -6,7 +6,7 @@ module Fog 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' @@ -94,6 +94,10 @@ module Fog 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] || '/' @@ -136,6 +140,16 @@ module Fog } ) + 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,