Skip to content

Commit

Permalink
Add resource name to log
Browse files Browse the repository at this point in the history
  • Loading branch information
dowied4 committed Nov 6, 2023
1 parent 2771c30 commit 7b7cca3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions push/cloudwatch/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def get_lambda_tags(opts = {})
Aws::Lambda::Client.new(retry_opts.merge(opts)).list_tags(
resource: 'arn:aws:lambda:' + ENV.fetch('REGION') + ':' + owner + ':function:' + log_group
).tags
rescue Aws::Lambda::Errors::ThrottlingException => e
puts "ThrottlingExceptionGetLambdaTags (retry attempt: #{retries}): #{e.inspect}"
rescue Aws::Lambda::Errors::ThrottlingException
puts "ThrottlingExceptionGetLambdaTags (retry attempt: #{retries}) - Retry attempt: #{retries}"
retry if (retries += 1) < 3

puts 'ThrottlingExceptionGetLambdaTagsRetryLimitExceeded'
Expand Down
2 changes: 1 addition & 1 deletion spec/push/cloudwatch/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
)
end

it 'raises exception when retry limit exceeded' do
it 'retries method 3 times' do
subject.to_loggly!
expect(Aws::Lambda::Client).to have_received(:new).exactly(3).times
end
Expand Down
4 changes: 2 additions & 2 deletions spec/subscribe/lambda/function_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
)
end

it 'raises exception when retry limit exceeded' do
it 'retries method 3 times for each function' do
described_class.new(
arn: 'test',
name: 'test',
Expand Down Expand Up @@ -260,7 +260,7 @@
)
end

it 'raises exception when retry limit exceeded' do
it 'retries method 3 times for each function' do
described_class.subscribe_all!(lambda, cloudwatch)
expect(cloudwatch).to have_received(:describe_subscription_filters).exactly(6).times
end
Expand Down
12 changes: 6 additions & 6 deletions subscribe/lambda/function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def filter_pattern
def fetch_tags!
retries ||= 0
lambda.list_tags(resource: arn).tags
rescue Aws::Lambda::Errors::ThrottlingException => e
puts "ThrottlingExceptionFetchTags (retry attempt: #{retries}): #{e.inspect}"
rescue Aws::Lambda::Errors::ThrottlingException
puts "ThrottlingExceptionFetchTags (Resource: #{name}) - Retry attempt: #{retries}"
retry if (retries += 1) < 3

puts 'ThrottlingExceptionFetchTagsRetryLimitExceeded'
puts "ThrottlingExceptionFetchTagsRetryLimitExceeded (Resource: #{name})"

[]
end
Expand All @@ -125,11 +125,11 @@ def subscriptions
limit: 1
).subscription_filters
end
rescue Aws::CloudWatchLogs::Errors::ThrottlingException => e
puts "ThrottlingExceptionSubscriptions (retry attempt: #{retries}): #{e.inspect}"
rescue Aws::CloudWatchLogs::Errors::ThrottlingException
puts "ThrottlingExceptionSubscriptions (Resource: #{name}) - Retry attempt: #{retries}"
retry if (retries += 1) < 3

puts 'ThrottlingExceptionSubscriptionsRetryLimitExceeded'
puts "ThrottlingExceptionSubscriptionsRetryLimitExceeded (Resource: #{name})"
[]
end

Expand Down

0 comments on commit 7b7cca3

Please sign in to comment.