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

aws-sdk-lambda fix #2939

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -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
Loading