-
Notifications
You must be signed in to change notification settings - Fork 5
/
sentry_example.ml
40 lines (36 loc) · 1.17 KB
/
sentry_example.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
open Core_kernel
open Async
(* Note: We currently require the Async scheduler to be running *)
let send_message =
let spec = Command.Spec.empty in
Command.async_spec ~summary:"Sends a message to Sentry" spec
@@ fun () ->
Sentry.merge_tags [ "subcommand", "send-message" ];
Sentry.add_breadcrumb
(Sentry.Breadcrumb.make_navigation
~from:"nothing"
~to_:"something"
~message:"first crumb"
());
Sentry.(add_breadcrumb (Breadcrumb.make ~message:"second crumb" ()));
Sentry.capture_message "test from OCaml" |> return
;;
let send_exn =
let spec = Command.Spec.empty in
Command.async_spec ~summary:"Sends an exception to Sentry" spec
@@ fun () ->
Sentry.merge_tags [ "subcommand", "send-exn" ];
Sentry.add_breadcrumb
(Sentry.Breadcrumb.make_navigation
~from:"nothing"
~to_:"something"
~message:"first crumb"
());
Sentry.(add_breadcrumb (Breadcrumb.make ~message:"second crumb" ()));
Sentry.with_exn_handler_ignore (fun () -> failwith "Test exception!") |> return
;;
let () =
[ "send-message", send_message; "send-exn", send_exn ]
|> Command.group ~summary:"Test commands for Sentry"
|> Command.run
;;