lib/fog/aws/dns.rb in fog-1.23.0 vs lib/fog/aws/dns.rb in fog-1.24.0
- old
+ new
@@ -4,22 +4,26 @@
module DNS
class AWS < Fog::Service
extend Fog::AWS::CredentialFetcher::ServiceMethods
requires :aws_access_key_id, :aws_secret_access_key
- recognizes :host, :path, :port, :scheme, :version, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at
+ recognizes :host, :path, :port, :scheme, :version, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :instrumentor, :instrumentor_name
model_path 'fog/aws/models/dns'
model :record
collection :records
model :zone
collection :zones
request_path 'fog/aws/requests/dns'
+ request :create_health_check
request :create_hosted_zone
+ request :delete_health_check
+ request :get_health_check
request :get_hosted_zone
request :delete_hosted_zone
+ request :list_health_checks
request :list_hosted_zones
request :change_resource_record_sets
request :list_resource_record_sets
request :get_change
@@ -88,10 +92,12 @@
def initialize(options={})
require 'fog/core/parser'
@use_iam_profile = options[:use_iam_profile]
setup_credentials(options)
+ @instrumentor = options[:instrumentor]
+ @instrumentor_name = options[:instrumentor_name] || 'fog.aws.dns'
@connection_options = options[:connection_options] || {}
@host = options[:host] || 'route53.amazonaws.com'
@path = options[:path] || '/'
@persistent = options.fetch(:persistent, true)
@port = options[:port] || 443
@@ -116,14 +122,26 @@
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
end
def request(params, &block)
refresh_credentials_if_expired
+
params[:headers] ||= {}
params[:headers]['Date'] = Fog::Time.now.to_date_header
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
params[:headers]['X-Amzn-Authorization'] = "AWS3-HTTPS AWSAccessKeyId=#{@aws_access_key_id},Algorithm=HmacSHA1,Signature=#{signature(params)}"
params[:path] = "/#{@version}/#{params[:path]}"
+
+ if @instrumentor
+ @instrumentor.instrument("#{@instrumentor_name}.request", params) do
+ _request(params, &block)
+ end
+ else
+ _request(params, &block)
+ end
+ end
+
+ def _request(params, &block)
@connection.request(params, &block)
end
def signature(params)
string_to_sign = params[:headers]['Date']