1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[AWS|DynamoDB] Add instrumentor

This commit is contained in:
Michael Hale 2014-09-16 13:41:17 -04:00
parent 78a84e1e12
commit 540b629c0d

View file

@ -6,7 +6,7 @@ module Fog
extend Fog::AWS::CredentialFetcher::ServiceMethods
requires :aws_access_key_id, :aws_secret_access_key
recognizes :aws_session_token, :host, :path, :port, :scheme, :persistent, :region, :use_iam_profile, :aws_credentials_expire_at
recognizes :aws_session_token, :host, :path, :port, :scheme, :persistent, :region, :use_iam_profile, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
request_path 'fog/aws/requests/dynamodb'
request :batch_get_item
@ -80,6 +80,8 @@ module Fog
setup_credentials(options)
@connection_options = options[:connection_options] || {}
@instrumentor = options[:instrumentor]
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.dynamodb'
@host = options[:host] || "dynamodb.#{@region}.amazonaws.com"
@path = options[:path] || '/'
@ -125,6 +127,16 @@ module Fog
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
params[:headers]['Authorization'] = @signer.sign(params, date)
if @instrumentor
@instrumentor.instrument("#{@instrumentor_name}.request", params) do
_request(params)
end
else
_request(params)
end
end
def _request(params)
response = @connection.request(params)
unless response.body.empty?
@ -133,6 +145,7 @@ module Fog
response
end
end
end
end