-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update log group tag handling #9
Conversation
def should_fetch_tags(log_group_name) | ||
# only fetch tags if | ||
# - there is no timestamp for when the tags were last updated | ||
# - OR the tags were last updated more than an hour ago (60 seconds * 60 minutes) | ||
@tag_cache[log_group_name][:last_updated].nil? || | ||
((Time.now - @tag_cache[log_group_name][:last_updated]) > (60 * 60)) | ||
end | ||
|
||
def fetch_tags(log_group_name) | ||
if @tag_cache.key?(log_group_name) | ||
return @tag_cache[log_group_name][:tags] | ||
else | ||
tags = fetch_tags_from_cloudwatch(log_group_name) | ||
@tag_cache[log_group_name] = { tags: tags} | ||
return tags | ||
end | ||
return @tag_cache[log_group_name][:tags] if @tag_cache.key?(log_group_name) && !should_fetch_tags(log_group_name) | ||
|
||
tags = fetch_tags_from_cloudwatch(log_group_name) | ||
@tag_cache[log_group_name] = { tags: tags, last_updated: Time.now } | ||
tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the only meaningful changes in the PR. The rest are formatting changes suggested by Rubocop which I do think makes the code more readable and maintainable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really like the changes
Changes proposed in this pull request:
Related to #8
Things to check
INFO
and debugging statements are written withlog.debug
or similar, then they won't be written to the otput, which can prevent unintentional leaks of sensitive data.Security considerations
None, just improving behavior of plugin so that tags are refreshed every hour