lib/honeycomb/integrations/aws.rb
# Propagates S3 region redirect information to the next aws-api span.
#
# When the AWS S3 client is configured with the wrong region, Amazon
# responds to API requests with an HTTP 400 indicating the correct region
# for the bucket.
#
# This error is normally caught upstream by stock plugins that trigger a
# new API request with the right region, which will create another
# aws-api span after this one. However, since the aws.region field set by
# {#add_aws_api_fields} comes from the aws-sdk configuration, its value
# would continue being wrong in the next aws-api span. Instead, we want
# this span to have the wrong region (that triggered the error) and the
# next span to have the right region (which won't come from the config).
#
# To update aws.region to the right value, {#handle_redirect} looks for a
# value stashed in the Seahorse::Client::Context#metadata. This is set by
# aws-sdk v3 (via the aws-sdk-s3 gem) but not by aws-sdk v2. So, we have
# to duplicate some of the upstream v3 logic in order to propagate the
# redirected region in the v2 case. We only do this in the v2 case in the
# hopes that eventually we don't have to maintain the duplicated logic.
#
# @see https://github.com/aws/aws-sdk-ruby/blob/379d338406873b0f4b53f118c83fe40761e297ab/gems/aws-sdk-s3/lib/aws-sdk-s3/plugins/s3_signer.rb#L151
Propagates S3 region redirect information to the next aws-api span.
When the AWS S3 client is configured with the wrong region, Amazon
responds to API requests with an HTTP 400 indicating the correct region
for the bucket.

This error is normally caught upstream by stock plugins that trigger a
new API request with the right region, which will create another
aws-api span after this one. However, since the aws.region field set by
{#add_aws_api_fields} comes from the aws-sdk configuration, its value
would continue being wrong in the next aws-api span. Instead, we want
this span to have the wrong region (that triggered the error) and the
next span to have the right region (which won't come from the config).

To update aws.region to the right value, {#handle_redirect} looks for a
value stashed in the Seahorse::Client::Context#metadata. This is set by
aws-sdk v3 (via the aws-sdk-s3 gem) but not by aws-sdk v2. So, we have
to duplicate some of the upstream v3 logic in order to propagate the
redirected region in the v2 case. We only do this in the v2 case in the
hopes that eventually we don't have to maintain the duplicated logic.
Propagates S3 region redirect information to the next aws - api span . When the AWS S3 client is configured with the wrong region Amazon responds to API requests with an HTTP 400 indicating the correct region for the bucket . This error is normally caught upstream by stock plugins that trigger a new API request with the right region which will create another aws - api span after this one . However since the aws . region field set by { #add_aws_api_fields } comes from the aws - sdk configuration its value would continue being wrong in the next aws - api span . Instead we want this span to have the wrong region ( that triggered the error ) and the next span to have the right region ( which won ' t come from the config ) . To update aws . region to the right value { #handle_redirect } looks for a value stashed in the Seahorse :: Client :: Context#metadata . This is set by aws - sdk v3 ( via the aws - sdk - s3 gem ) but not by aws - sdk v2 . So we have to duplicate some of the upstream v3 logic in order to propagate the redirected region in the v2 case . We only do this in the v2 case in the hopes that eventually we don ' t have to maintain the duplicated logic .
def process_s3_region(context)
        return unless SDK_VERSION.start_with?("2.")
        redirect = S3Redirect.new(context)
        context[:redirect_region] = redirect.region if redirect.happening?
      end
def process_s3_region ( context ) return unless SDK_VERSION . start_with? ( "2." ) redirect = S3Redirect . new ( context ) context [ :redirect_region ] = redirect . region if redirect . happening? end
Propagates S3 region redirect information to the next aws-api span.
Propagates S3 region redirect information to the next aws - api span .
context
<not_specific>
see
None