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

log noisy AnimationBucketWarning to firehose, not honeybadger #24778

Merged
merged 3 commits into from Sep 13, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions shared/middleware/helpers/animation_bucket.rb
@@ -1,3 +1,5 @@
require 'cdo/firehose'

#
# AnimationBucket
#
Expand Down Expand Up @@ -45,16 +47,18 @@ def s3_get_object(key, if_modified_since, version)
# Try getting the first (non-delete-marker) version
s3_object = super(key, if_modified_since, versions.first.version_id)

# If the fallback is successful, let's notify Honeybadger, because we'd
# If the fallback is successful, let's notify Firehose, because we'd
# like these to go down over time.
Honeybadger.notify(
error_class: "#{self.class.name}Warning",
error_message: 'AnimationBucket served latest version instead of requested version',
context: {
FirehoseClient.instance.put_record(
study: 'bucket-warning',
study_group: self.class.name,
event: 'served-latest-version',
data_string: 'AnimationBucket served latest version instead of requested version',
data_json: {
s3_key: key,
requested_version: version,
served_version: s3_object.version_id
}
}.to_json
)
s3_object
end
Expand Down
24 changes: 14 additions & 10 deletions shared/middleware/helpers/bucket_helper.rb
Expand Up @@ -392,24 +392,28 @@ def restore_previous_version(encrypted_channel_id, filename, version_id, user_id
}
)
version_restored = true
Honeybadger.notify(
error_class: "#{self.class.name}Warning",
error_message: "Restore at Specified Version Failed. Restored most recent.",
context: {
FirehoseClient.instance.put_record(
study: 'bucket-warning',
study_group: self.class.name,
event: 'restore-specific-version',
data_string: 'Restore at Specified Version Failed. Restored most recent.',
data_json: {
source: "#{@bucket}/#{key}?versionId=#{version_id}"
}
}.to_json
)
else
# Couldn't restore specific version and didn't find a latest version either.
# It is probably deleted.
# In this case, we want to do nothing.
response = {status: 'NOT_MODIFIED'}
Honeybadger.notify(
error_class: "#{self.class.name}Warning",
error_message: "Restore at Specified Version Failed on deleted object. No action taken.",
context: {
FirehoseClient.instance.put_record(
study: 'bucket-warning',
study_group: self.class.name,
event: 'restore-deleted-object',
data_string: 'Restore at Specified Version Failed on deleted object. No action taken.',
data_json: {
source: "#{@bucket}/#{key}?versionId=#{version_id}"
}
}.to_json
)
end
end
Expand Down
10 changes: 7 additions & 3 deletions shared/test/test_animations.rb
Expand Up @@ -97,6 +97,7 @@ def test_nonexistent_animation
soft_delete(filename) # Not a no-op - creates a delete marker

Honeybadger.expects(:notify).never
FirehoseClient.any_instance.expects(:put_record).never
@api.get_object(filename)
assert not_found?
end
Expand All @@ -119,7 +120,8 @@ def test_get_bad_version_returns_latest_version
upload(filename, v2_file_data)

# Ask for the missing version
Honeybadger.expects(:notify).once
Honeybadger.expects(:notify).never
FirehoseClient.any_instance.expects(:put_record).once
@api.get_object_version(filename, v1_version_id)
assert successful?

Expand Down Expand Up @@ -149,7 +151,8 @@ def test_get_bad_version_returns_latest_nondeleted_version
soft_delete(filename)

# Ask for the missing version
Honeybadger.expects(:notify).once
Honeybadger.expects(:notify).never
FirehoseClient.any_instance.expects(:put_record).once
@api.get_object_version(filename, v1_version_id)
assert successful?

Expand All @@ -170,8 +173,9 @@ def test_get_bad_version_is_404_when_all_versions_are_deleted
delete_all_animation_versions(filename)

# Ask for an invalid version
# No Honeybadger notification on this case - it's an expected 404.
Honeybadger.expects(:notify).never
# No Firehose notification on this case - it's an expected 404.
FirehoseClient.any_instance.expects(:put_record).never
@api.get_object_version(filename, v1_version_id)
assert not_found?
end
Expand Down