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

empty string in ruby is not falsy, adding empty? check to only add tag dimension if it is present #44

Merged
merged 2 commits into from
Feb 24, 2025

Conversation

taimoordev
Copy link

This PR is opened against this issue

Where the check if process["tag"] is returning true in case of empty string, which caused the issue for aws-sdk-cloudwatch library
image

@@ -189,7 +189,7 @@ def publish
unless process_utilization.nan?
process_dimensions = [{name: "Hostname", value: process["hostname"]}]

if process["tag"]
unless process['tag'].empty?
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that process["tag"] is nil?

if process["tag"] && !process["tag"].empty?

(Please keep in mind I'm a random dev and not the repository maintainer.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, for those apps which are Rails based
Yes, for those apps which are only Ruby based

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run into the same error. Can this be merged in please

@sj26
Copy link
Owner

sj26 commented Feb 24, 2025

Nice find, thanks!

@sj26
Copy link
Owner

sj26 commented Feb 24, 2025

Ah, now this introduced another error:

  2) Sidekiq::CloudWatchMetrics Publisher #publish with lots of queues publishes sidekiq metrics to cloudwatch in batches of 20
     Failure/Error: unless process["tag"].empty?

     NoMethodError:
       undefined method `empty?' for nil:NilClass
     # ./lib/sidekiq/cloudwatchmetrics.rb:192:in `block in publish'
     # ./lib/sidekiq/cloudwatchmetrics.rb:186:in `each'
     # ./lib/sidekiq/cloudwatchmetrics.rb:186:in `publish'
     # ./spec/sidekiq/cloudwatchmetrics_spec.rb:216:in `block (6 levels) in <top (required)>'
     # ./vendor/bundle/ruby/3.0.0/gems/timecop-0.9.10/lib/timecop/timecop.rb:225:in `travel'
     # ./vendor/bundle/ruby/3.0.0/gems/timecop-0.9.10/lib/timecop/timecop.rb:155:in `send_travel'
     # ./vendor/bundle/ruby/3.0.0/gems/timecop-0.9.10/lib/timecop/timecop.rb:58:in `freeze'
     # ./spec/sidekiq/cloudwatchmetrics_spec.rb:215:in `block (5 levels) in <top (required)>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants