View Source Sentry.CheckIn (Sentry v10.2.0)
This module represents the struct for a "check-in".
Check-ins are used to report the status of a monitor to Sentry. This is used to track the health and progress of cron jobs. This module is somewhat low level, and mostly useful when you want to report the status of a cron but you are not using any common library to manage your cron jobs.
Using
capture_check_in/1
Instead of using this module directly, you'll probably want to use
Sentry.capture_check_in/1
to manually report the status of your cron jobs.
See https://develop.sentry.dev/sdk/check-ins/. This struct is available since v10.2.0.
Link to this section Summary
Types
The possible values for the :schedule
option under :monitor_config
.
The possible status of the check-in.
The type for the check-in struct.
Link to this section Types
@type monitor_config_schedule() :: %{type: :crontab, value: String.t()} | %{ type: :interval, value: number(), unit: :year | :month | :week | :day | :hour | :minute }
The possible values for the :schedule
option under :monitor_config
.
If the :type
is :crontab
, then the :value
must be a string representing
a crontab expression. If the :type
is :interval
, then the :value
must be
a number representing the interval and the :unit
must be present and be one of :year
,
:month
, :week
, :day
, :hour
, or :minute
.
@type status() :: :in_progress | :ok | :error
The possible status of the check-in.
@type t() :: %Sentry.CheckIn{ check_in_id: String.t(), contexts: Sentry.Interfaces.context(), duration: float() | nil, environment: String.t() | nil, monitor_config: nil | %{ :schedule => monitor_config_schedule(), optional(:checkin_margin) => number(), optional(:max_runtime) => number(), optional(:failure_issue_threshold) => number(), optional(:recovery_threshold) => number(), optional(:timezone) => String.t() }, monitor_slug: String.t(), release: String.t() | nil, status: status() }
The type for the check-in struct.
Link to this section Functions
Creates a new check-in struct with the given options.
options
Options
The options you can pass match a subset of the fields of the t/0
struct.
You can pass:
:check_in_id
(String.t/0
):status
(status/0
) - Required.:monitor_slug
(String.t/0
) - Required.:duration
(number/0
):contexts
(map/0
) - The contexts to attach to the check-in. This is a map of arbitrary data, but right now Sentry supports thetrace_id
key under the trace context to connect the check-in with related errors. The default value is%{}
.:monitor_config
(keyword/0
) - If you pass this optional option, you must pass the nested:schedule
option.:checkin_margin
(number/0
):max_runtime
(number/0
):failure_issue_threshold
(number/0
):recovery_threshold
(number/0
):timezone
(String.t/0
):schedule
(monitor_config_schedule/0
)
examples
Examples
iex> check_in = CheckIn.new(status: :ok, monitor_slug: "my-slug")
iex> check_in.status
:ok
iex> check_in.monitor_slug
"my-slug"