From 6469cf70c87f1cd2dbd3f4d72394427293abb9ea Mon Sep 17 00:00:00 2001 From: Vladimir Babin Date: Wed, 23 Sep 2026 17:55:57 +0300 Subject: [PATCH] fix(crons): Log debug message when monitor config interval unit is invalid --- sentry-ruby/lib/sentry/cron/monitor_config.rb | 10 +++++++++- .../spec/sentry/cron/monitor_config_spec.rb | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sentry-ruby/lib/sentry/cron/monitor_config.rb b/sentry-ruby/lib/sentry/cron/monitor_config.rb index 36d7b52e8..102ed4d35 100644 --- a/sentry-ruby/lib/sentry/cron/monitor_config.rb +++ b/sentry-ruby/lib/sentry/cron/monitor_config.rb @@ -35,7 +35,15 @@ def self.from_crontab(crontab, **options) end def self.from_interval(num, unit, **options) - return nil unless MonitorSchedule::Interval::VALID_UNITS.include?(unit) + unless MonitorSchedule::Interval::VALID_UNITS.include?(unit) + if Sentry.initialized? + Sentry.sdk_logger.debug(LOGGER_PROGNAME) do + "Invalid interval unit #{unit.inspect} for monitor config, must be one of #{MonitorSchedule::Interval::VALID_UNITS.inspect}" + end + end + + return nil + end new(MonitorSchedule::Interval.new(num, unit), **options) end diff --git a/sentry-ruby/spec/sentry/cron/monitor_config_spec.rb b/sentry-ruby/spec/sentry/cron/monitor_config_spec.rb index 11dd57952..28be1d0e8 100644 --- a/sentry-ruby/spec/sentry/cron/monitor_config_spec.rb +++ b/sentry-ruby/spec/sentry/cron/monitor_config_spec.rb @@ -25,6 +25,21 @@ expect(described_class.from_interval(5, :bla)).to eq(nil) end + it 'logs a debug message without valid unit' do + string_io = StringIO.new + Sentry.configuration.sdk_logger = Logger.new(string_io) + + described_class.from_interval(5, :bla) + + expect(string_io.string).to include("Invalid interval unit :bla for monitor config") + end + + it 'returns nil without valid unit when SDK is not initialized' do + allow(Sentry).to receive(:initialized?).and_return(false) + + expect(described_class.from_interval(5, :bla)).to eq(nil) + end + it 'has correct attributes' do subject = described_class.from_interval( 5,