Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional metrics collection #3099

Merged
merged 8 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,18 @@ module {{module_name}}
context[:auth_scheme] =
Aws::Endpoints.resolve_auth_scheme(context, endpoint)

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

private

def with_endpoint_metric(config, &block)
return block.call if config.regional_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)
def with_metrics(context, &block)
metrics = []
metrics << 'ENDPOINT_OVERRIDE' unless context.config.regional_endpoint
if context[:auth_scheme] && context[:auth_scheme]['name'] == 'sigv4a'
metrics << 'SIGV4A_SIGNING'
end
Aws::Plugins::UserAgent.metric(*metrics, &block)
end

def apply_endpoint_headers(context, headers)
Expand Down
4 changes: 2 additions & 2 deletions build_tools/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class ServiceEnumerator
MANIFEST_PATH = File.expand_path('../../services.json', __FILE__)

# Minimum `aws-sdk-core` version for new gem builds
MINIMUM_CORE_VERSION = "3.203.1"
MINIMUM_CORE_VERSION = "3.204.1"

# Minimum `aws-sdk-core` version for new S3 gem builds
MINIMUM_CORE_VERSION_S3 = "3.203.1"
MINIMUM_CORE_VERSION_S3 = "3.204.1"

EVENTSTREAM_PLUGIN = "Aws::Plugins::EventStreamConfiguration"

Expand Down
15 changes: 8 additions & 7 deletions gems/aws-sdk-core/lib/aws-sdk-core/plugins/user_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ def self.feature(_feature, &block)
block.call
end

def self.metric(metric, &block)
def self.metric(*metrics, &block)
Thread.current[:aws_sdk_core_user_agent_metric] ||= []
Thread.current[:aws_sdk_core_user_agent_metric] << METRICS[metric]
metrics = metrics.map { |metric| METRICS[metric] }
mullermp marked this conversation as resolved.
Show resolved Hide resolved
Thread.current[:aws_sdk_core_user_agent_metric].concat(metrics)
block.call
ensure
Thread.current[:aws_sdk_core_user_agent_metric].pop
if Thread.current[:aws_sdk_core_user_agent_metric].empty?
Thread.current[:aws_sdk_core_user_agent_metric] = nil
end
Thread.current[:aws_sdk_core_user_agent_metric].pop(metrics.size)
end

# @api private
Expand Down Expand Up @@ -169,7 +167,10 @@ def framework_metadata
end

def metric_metadata
return unless Thread.current[:aws_sdk_core_user_agent_metric]
if Thread.current[:aws_sdk_core_user_agent_metric].nil? ||
Thread.current[:aws_sdk_core_user_agent_metric].empty?
return
end

metrics = Thread.current[:aws_sdk_core_user_agent_metric].join(',')
# Metric metadata is limited to 1024 bytes
Expand Down