class Honeycomb::Aws::SdkHandler

An AWS plugin handler that creates spans around SDK calls.

Each aws-sdk client provides a one-to-one mapping of methods to logical API operations. {SdkHandler} is responsible for starting the root level AWS span for the SDK method being called.

{Plugin} accomplishes this by adding the handler early in the process, around the initialization step. This doesn't necessarily represent the network latency of the API requests being made to Amazon, since SDK calls might involve several underlying operations: request signing, response parsing, retries, redirects, etc. Thus, {ApiHandler} is responsible for creating child spans around individual HTTP API calls. The span created by {SdkHandler} represents the overall result of the method call you made to the aws-sdk client.

Public Instance Methods

call(context) click to toggle source
# File lib/honeycomb/integrations/aws.rb, line 86
def call(context)
  setup(context)
  response = @handler.call(context)
  teardown(context, response.error)
  response
rescue StandardError => e
  teardown(context, e)
  raise e
ensure
  finish(context)
end

Private Instance Methods

finish(context) click to toggle source
# File lib/honeycomb/integrations/aws.rb, line 127
def finish(context)
  span = context.metadata.delete(:honeycomb_aws_sdk_span)
  span.send
end
setup(context) click to toggle source
# File lib/honeycomb/integrations/aws.rb, line 100
def setup(context)
  span = context.config.honeycomb_client.start_span(name: "aws-sdk")
  context[:honeycomb_aws_sdk_span] = span
  context[:honeycomb_aws_sdk_data] = {
    "meta.package" => context[:gem_name] || "aws-sdk",
    "meta.package_version" => context[:gem_version] || SDK_VERSION,
    "aws.region" => context.config.region,
    "aws.service" => context.client.class.identifier,
    "aws.operation" => context.operation_name,
  }

  context.params && context.params.each do |key, value|
    context[:honeycomb_aws_sdk_data]["aws.params.#{key}"] = value
  end

  span.add context[:honeycomb_aws_sdk_data]
end
teardown(context, error) click to toggle source
# File lib/honeycomb/integrations/aws.rb, line 118
def teardown(context, error)
  span = context[:honeycomb_aws_sdk_span]
  span.add_field "aws.request_id", context[:request_id]
  span.add_field "aws.retries", context.retries
  span.add_field "aws.retry_limit", context.config.retry_limit
  span.add_field "aws.error", error.class.name if error
  span.add_field "aws.error_detail", error.message if error
end