Report runtime exceptions to


Intialise a client with your DSN and environment name.

  import gleam_sentry as sentry

  let dsn = ""
  let environment = "production"
  assert Ok(client) = sentry.init(dsn, environment)

Capture an exception

sentry.capture_exception(client, reason, stacktrace, timestamp)

The types for reason and stacktrace are defined in the gleam/beam project along with cast functions that allow you to get these values form logger events.

Logger integration

// my_app/logger.gleam
import gleam/beam.{ExitReason, Stacktrace}

pub fn handle(client, reason: ExitReason, stacktrace: Stacktrace, timestamp) {
  sentry.capture_exception(client, reason, stacktrace, timestamp)
// During startup
import gleam/beam/logger
import my_app/logger as my_logger

pub fn start(){
  logger.add_handler(my_logger.handle(client, _, _, _))


gleam_sentry currently reports errors from the beam runtime system, and as such could be implemented as an erlang library. I have not used existing projects (see prior art below) as only Elixir projects are based on the new logger.

I would like this project to be useful in erlang projects. It would also be interesting to have a more general purpose span/context/error handling framework that this could plug in to.

Prior Art


erlang project, integrates with lager and error_logger.


Elixir project, uses new logger