Skip to content

Commit

Permalink
Move sigv4a metric to endpoints plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Sep 6, 2024
1 parent 5e8cafd commit 0cdb3dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,27 @@ module {{module_name}}
context[:auth_scheme] =
Aws::Endpoints.resolve_auth_scheme(context, endpoint)

with_metric(context[:endpoint_params]) { @handler.call(context) }
with_endpoint_metric(context[:endpoint_params]) do
with_sigv4a_metric(context[:auth_scheme]) do
@handler.call(context)
end
end
end

private

def with_metric(params, &block)
return block.call unless params && params[:endpoint]
def with_endpoint_metric(endpoint_params, &block)
return block.call unless endpoint_params && endpoint_params[:endpoint]

Aws::Plugins::UserAgent.metric('ENDPOINT_OVERRIDE', &block)
end

def with_sigv4a_metric(auth_scheme, &block)
return block.call unless auth_scheme && auth_scheme['name'] == 'sigv4a'

Aws::Plugins::UserAgent.metric('SIGV4A_SIGNING', &block)
end

def apply_endpoint_headers(context, headers)
headers.each do |key, values|
value = values
Expand Down
8 changes: 1 addition & 7 deletions gems/aws-sdk-core/lib/aws-sdk-core/plugins/sign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,11 @@ def call(context)
)
signer.sign(context)
end
with_metric(context[:auth_scheme]) { @handler.call(context) }
@handler.call(context)
end

private

def with_metric(auth_scheme, &block)
return block.call unless auth_scheme && auth_scheme['name'] == 'sigv4a'

Aws::Plugins::UserAgent.metric('SIGV4A_SIGNING', &block)
end

def v2_signing?(config)
# 's3' is legacy signing, 'v4' is default
config.respond_to?(:signature_version) &&
Expand Down

0 comments on commit 0cdb3dd

Please sign in to comment.