Skip to content

Commit 04c5452

Browse files
Add :owner option for check-ins (#879)
Co-authored-by: Andrea Leopardi <[email protected]>
1 parent 106ea15 commit 04c5452

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

lib/sentry/check_in.ex

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,24 @@ defmodule Sentry.CheckIn do
4040
unit: :year | :month | :week | :day | :hour | :minute
4141
}
4242

43+
@typedoc """
44+
The type for the monitor_config that can be part of the checking
45+
"""
46+
@typedoc since: "10.10.0"
47+
@type monitor_config() :: %{
48+
required(:schedule) => monitor_config_schedule(),
49+
optional(:checkin_margin) => number(),
50+
optional(:max_runtime) => number(),
51+
optional(:failure_issue_threshold) => number(),
52+
optional(:recovery_threshold) => number(),
53+
optional(:timezone) => String.t(),
54+
optional(:owner) => String.t()
55+
}
56+
4357
@typedoc """
4458
The type for the check-in struct.
59+
60+
`:owner` within `:monitor_config` is available since v10.10.0.
4561
"""
4662
@type t() :: %__MODULE__{
4763
check_in_id: String.t(),
@@ -50,16 +66,7 @@ defmodule Sentry.CheckIn do
5066
duration: float() | nil,
5167
release: String.t() | nil,
5268
environment: String.t() | nil,
53-
monitor_config:
54-
nil
55-
| %{
56-
required(:schedule) => monitor_config_schedule(),
57-
optional(:checkin_margin) => number(),
58-
optional(:max_runtime) => number(),
59-
optional(:failure_issue_threshold) => number(),
60-
optional(:recovery_threshold) => number(),
61-
optional(:timezone) => String.t()
62-
},
69+
monitor_config: nil | monitor_config(),
6370
contexts: Interfaces.context()
6471
}
6572

@@ -127,6 +134,7 @@ defmodule Sentry.CheckIn do
127134
failure_issue_threshold: number_schema_opts,
128135
recovery_threshold: number_schema_opts,
129136
timezone: [type: :string],
137+
owner: [type: :string],
130138
schedule: [
131139
type:
132140
{:or,

test/sentry/check_in_test.exs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,31 @@ defmodule Sentry.CheckInTest do
9393
)
9494
end
9595
end
96+
97+
test "works with a monitor config including owner" do
98+
assert %CheckIn{
99+
check_in_id: check_in_id,
100+
monitor_slug: "my-slug",
101+
status: :ok,
102+
environment: "test",
103+
monitor_config: %{
104+
schedule: %{
105+
type: :crontab,
106+
value: "0 * * * *"
107+
},
108+
owner: "team:my-cool-team"
109+
}
110+
} =
111+
CheckIn.new(
112+
status: :ok,
113+
monitor_slug: "my-slug",
114+
monitor_config: [
115+
schedule: [type: :crontab, value: "0 * * * *"],
116+
owner: "team:my-cool-team"
117+
]
118+
)
119+
120+
assert is_binary(check_in_id) and byte_size(check_in_id) > 0
121+
end
96122
end
97123
end

0 commit comments

Comments
 (0)