Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/sentry/integrations/quantum/cron.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ defmodule Sentry.Integrations.Quantum.Cron do
check_in_id: id,
# This is already a binary.
monitor_slug: "quantum-#{slugify(job.name)}",
monitor_config: [schedule: schedule_opts, timezone: timezone_to_string(job)]
monitor_config:
Keyword.merge(
Sentry.Config.integrations()[:monitor_config_defaults],
schedule: schedule_opts,
timezone: timezone_to_string(job)
)
]
end
else
Expand Down
39 changes: 39 additions & 0 deletions test/sentry/integrations/quantum/cron_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,45 @@ defmodule Sentry.Integrations.Quantum.CronTest do
)
end

test "uses default monitor configuration in Sentry's config if present", %{ref: ref} do
put_test_config(
integrations: [
monitor_config_defaults: [
checkin_margin: 10,
max_runtime: 42,
failure_issue_threshold: 84
]
]
)

span_ref = make_ref()

:telemetry.execute([:quantum, :job, :start], %{}, %{
job:
Scheduler.new_job(
name: :test_job,
schedule: Crontab.CronExpression.Parser.parse!("@daily"),
timezone: "Europe/Rome"
),
telemetry_span_context: span_ref
})

[check_in_body] = SentryTest.collect_sentry_check_ins(ref, 1)

assert_sentry_report(check_in_body,
monitor_config: %{
"checkin_margin" => 10,
"failure_issue_threshold" => 84,
"max_runtime" => 42,
"schedule" => %{
"type" => "crontab",
"value" => "0 0 * * * *"
},
"timezone" => "Europe/Rome"
}
)
end

test "captures exception events with monitor config", %{ref: ref} do
span_ref = make_ref()
id = CheckInIDMappings.lookup_or_insert_new("quantum-#{:erlang.phash2(span_ref)}")
Expand Down
Loading