mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|compute] Add instrumentation support.
This commit is contained in:
parent
73467e71ea
commit
6cecc5f0a9
1 changed files with 24 additions and 16 deletions
|
@ -7,7 +7,7 @@ module Fog
|
|||
extend Fog::AWS::CredentialFetcher::ServiceMethods
|
||||
|
||||
requires :aws_access_key_id, :aws_secret_access_key
|
||||
recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, :aws_session_token, :use_iam_profile, :aws_credentials_expire_at
|
||||
recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, :aws_session_token, :use_iam_profile, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
|
||||
|
||||
secrets :aws_secret_access_key, :hmac, :aws_session_token
|
||||
|
||||
|
@ -315,6 +315,8 @@ module Fog
|
|||
setup_credentials(options)
|
||||
@connection_options = options[:connection_options] || {}
|
||||
@region = options[:region] ||= 'us-east-1'
|
||||
@instrumentor = options[:instrumentor]
|
||||
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.compute'
|
||||
|
||||
if @endpoint = options[:endpoint]
|
||||
endpoint = URI.parse(@endpoint)
|
||||
|
@ -364,8 +366,17 @@ module Fog
|
|||
}
|
||||
)
|
||||
|
||||
begin
|
||||
response = @connection.request({
|
||||
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' },
|
||||
|
@ -387,9 +398,6 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue