Skip to content

Commit

Permalink
Merge pull request #2939 from newrelic/half-life
Browse files Browse the repository at this point in the history
aws-sdk-lambda fix
  • Loading branch information
fallwith authored Nov 7, 2024
2 parents d056cfe + e96cc35 commit 1d70cad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ def with_tracing(action, *args)
# creating any segments that may appear as redundant / confusing
NewRelic::Agent.disable_all_tracing do
response = NewRelic::Agent::Tracer.capture_segment_error(segment) { yield }
begin
process_response(response, segment)
rescue => e
NewRelic::Agent.logger.error("Error processing aws-sdk-lambda invocation response (action = #{action}): #{e}")
ensure
response
end
process_response(response, segment)
response
end
ensure
segment&.finish
Expand All @@ -47,6 +42,8 @@ def with_tracing(action, *args)
def process_response(response, segment)
process_status_code(response, segment) if response.respond_to?(:status_code)
process_function_error(response) if response.respond_to?(:function_error)
rescue => e
NewRelic::Agent.logger.error("Error processing aws-sdk-lambda invocation response: #{e}")
end

def process_status_code(response, segment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def test_client_call_raises_an_exception

def test_errors_in_processing_the_invocation_response_are_logged_but_not_raised_to_the_user_app
in_transaction do |txn|
client = Aws::Lambda::Client.new(region: REGION)
response = {status_code: 200}
client = Aws::Lambda::Client.new(region: REGION, stub_responses: {invoke: response})
client.config.account_id = AWS_ACCOUNT_ID
def client.process_response(*_args); raise 'kaboom'; end
def client.process_status_code(*_args); raise 'kaboom'; end

NewRelic::Agent.stub(:logger, NewRelic::Agent::MemoryLogger.new) do
client.invoke(function_name: 'Invoke-Me-And-Only-The-Agent-Explodes')
Expand Down

0 comments on commit 1d70cad

Please sign in to comment.