Purple-Devs / health_check

Simple health check of Rails app for use with uptime checking sites like newrelic and pingdom
MIT License
474 stars 125 forks source link

Why add the dot at the end of the message within the gem? #113

Open lcx opened 3 years ago

lcx commented 3 years ago

I was wondering why my specs where suddenly failing after updating the gem.

CleanShot 2021-07-28 at 12 33 41

Which led me to this change: https://github.com/ianheggie/health_check/commit/6269b9dc351633758d6800db55ce20a833422c28#diff-62b6b428a662cf081fc326b69c57f59ac43aa727604a75eccfde66538031827fR93

It's a quick fix on my side but why modify the existing message within the gem? What problem does it solve? Also somehow in some situations I'm seeing two dots at the end 🤔 Just noticed that it expects dot + space, but still I get an additional dot added.

lcx commented 3 years ago

ok, now I see. my error message looks like this

"C: cdr / host last imported at 2021-07-28 08:49:22. "

it does nothing at this line since errors.end_with?('. ') returns true.

errors << '. ' unless errors == '' || errors.end_with?('. ')

then it continues with return errors.strip which now returns C: cdr / host last imported at 2021-07-28 08:49:22. without the space. Then it get's back into process_checks, now errors being C: cdr / host last imported at 2021-07-28 08:49:22. without the space in the end so a period + space is entered again.

lcx commented 3 years ago

a bit of further digging, if I call get '/health_check/all.json' it will run

when "all", "full"
  errors << HealthCheck::Utils.process_checks(HealthCheck.full_checks, called_from_middleware)

here I will get the errors stripped of the space. but at the end it will run into

errors << '. ' unless errors == '' || errors.end_with?('. ')

again and add a second period.