package sentry

  1. Overview
  2. Docs
Unofficial Async Sentry error monitoring client

Install

Dune Dependency

Authors

Maintainers

Sources

sentry-v0.10.1.tbz
sha256=bf6356599923dfd043d933f0fe9f876dd88c6c0c9ba05dcaf9fed74e9621fec2
sha512=43d81f211cea1e411eb969c371b2181969c0357931fdadecc05432c6d61c28e72af5af8c22c72abd27cf4508845915148c84a805057313c526c70ae3d17e439d

Description

Sentry is an unofficial Async OCaml client for the Sentry error reporting.

Published: 08 May 2020

README

README.md

Sentry (OCaml) - WORK IN PROGRESS

This is an unofficial work-in-progress Sentry library for OCaml.

This currently requires the Async scheduler to be running or data will not be uploaded

Missing features:

  • Only supports Async (pull requests to factor out Lwt/Unix are welcome!)

  • Global unhandled exception handler isn't implemented yet.

  • Probably other things

Example

See the example program.

In general, you should use this like:

let () =
  let spec = Command.Spec.(...) in
  Command.async_spec ~summary:"..." spec @@ fun args () ->
  (* Using [SENTRY_DSN] from the environment *)
  Sentry.with_exn_handler @@ fun () ->
  (* your normal code here *)

To release the warning above: The Async schedule must be running.

This will execute your code as usual, and if it throws an exception, it will be uploaded to Sentry:

Then the exception will be re-thrown so your program will exit and print the backtrace to stderr as usual (if you want to continue after errors, wrap Sentry.with_exn_handler in another error handler or use Sentry.with_exn_handler_ignore).

Note that Sentry.with_error_and_exn_handler exists (which handles both exceptions and Or_error.t), but using exceptions exclusively is recommended because they have backtraces (and wrapping exceptions in Error.t loses whatever backtrace did exist in most cases).

Tags

We upload some data by default. From environment variables, we get:

  • SENTRY_ENVIRONMENT -> environment

  • SENTRY_RELEASE -> release

From Sys or Unix:

  • Sys.argv -> argv

  • Sys.backend_type -> backend_type

  • Sys.executable_name -> executable_name

  • Sys.gethostname -> server_name

  • Sys.os_type -> os_type

You can override any of these with Sentry.merge_extra, Sentry.set_environment, and Sentry.set_release.

You can also upload custom tags using either Sentry.merge_tags or by passing ~tags to a capture function. Tags will be merged for the current async job, so you only need to pass additional tags:

Sentry.merge_tags [ "app_name", "http_server" ];
Sentry.with_exn_handler @@ fun () ->
...
Sentry.merge_tags [ "method", "GET", "path", "/example" ];
...
(* This will upload with default tags + app_name, method, path, and user_id *)
Sentry.capture_message ~tags:[ "user_id", user_id ] "invalid login"

Dependencies (14)

  1. yojson < "2.0.0"
  2. uri
  3. uuidm
  4. sexplib >= "v0.13.0" & < "v0.14"
  5. re2 < "v0.14"
  6. ocaml >= "4.08.0"
  7. ppx_jane < "v0.14"
  8. json-derivers
  9. hex >= "1.2.0"
  10. dune >= "1.11.0"
  11. cohttp-async >= "2.0.0"
  12. cohttp >= "2.0.0"
  13. atdgen < "2.10.0"
  14. async_unix >= "v0.13.0" & < "v0.14"

Dev Dependencies (1)

  1. bisect_ppx dev & >= "2.0.0"

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.