A Sentry SDK for Racket
1 Introduction
2 API Stability
3 Quickstart
4 Reference
4.1 Core API
sentry?
current-sentry
make-sentry
sentry-capture-exception!
4.2 Users
sentry-user?
current-sentry-user
make-sentry-user
Index
7.4

A Sentry SDK for Racket

Bogdan Popa <bogdan@defn.io>

 (require sentry) package: sentry-lib

1 Introduction

This library provides an interface for capturing and sending errors to either a managed or a self-hosted Sentry instance.

2 API Stability

This package is pre-1.0 and its API may change without notice!

3 Quickstart

Install the package from the package server with

$ raco pkg install sentry

Call make-sentry to create an instance of the sentry client. Keep a reference to the client around for as long as your application needs to run and you can start sending exceptions by calling sentry-capture-exception!:

(require sentry)
 
(parameterize ([current-sentry (make-sentry "https://key@sentry.io/12")])
  (sentry-capture-exception! (make-exn:fail "an error" (current-continuation-marks))))

4 Reference

4.1 Core API

procedure

(sentry? v)  boolean?

  v : any/c
Returns #t when v is a Sentry client.

parameter

(current-sentry)  sentry?

(current-sentry client)  void?
  client : sentry?
A parameter that can store the current Sentry client for use with sentry-capture-exception!.

procedure

(make-sentry dsn    
  [#:backlog backlog    
  #:release release    
  #:environment environment])  sentry?
  dsn : string?
  backlog : exact-positive-integer? = 128
  release : (or/c false/c non-empty-string?)
   = (getenv "SENTRY_RELEASE")
  environment : (or/c false/c non-empty-string?)
   = (getenv "SENTRY_ENVIRONMENT")
Initialize a Sentry client and start the background thread that will send errors to the API.

backlog specifies the size of the error queue. When the queue fills up, calls to sentry-capture-exception! will start to block so you need to size this appropriately.

release can be set to tag each error with the current release (usually a GIT SHA).

environment can be set to tag each error with the current environment (eg. "production" or "staging").

Sentry clients log messages to the 'sentry topic.

procedure

(sentry-capture-exception! e    
  [client    
  #:level level    
  #:timestamp timestamp    
  #:server-name server-name    
  #:environment environment    
  #:release release    
  #:request request    
  #:tags tags    
  #:user user])  void?
  e : exn?
  client : (or/c false/c sentry?) = (current-sentry)
  level : (or/c 'fatal 'error 'warning 'info 'debug) = 'error
  timestamp : moment? = (now/moment)
  server-name : (or/c false/c non-empty-string?) = #f
  environment : (or/c false/c non-empty-string?) = #f
  release : (or/c false/c non-empty-string?) = #f
  request : (or/c false/c request?) = #f
  tags : (hash/c non-empty-string? string?) = (hash)
  user : sentry-user? = (current-sentry-user)
Asynchronously send an error to the Sentry API.

Does nothing when client is #f.

4.2 Users

procedure

(sentry-user? v)  boolean?

  v : any/c
Returns #t when v represents a Sentry user.

A parameter that keeps track of data for the current user.

sentry-capture-exception! automatically picks these values up unless a different value is specified via its #:user argument.

procedure

(make-sentry-user #:id id    
  [#:username username    
  #:email email    
  #:ip-address ip-address    
  #:subscription subscription])  sentry-user?
  id : non-empty-string?
  username : (or/c false/c non-empty-string?) = #f
  email : (or/c false/c non-empty-string?) = #f
  ip-address : (or/c false/c non-empty-string?) = #f
  subscription : (or/c false/c non-empty-string?) = #f
Creates an object that can store various bits of information about a user. These can then be passed to sentry-capture-exception! to have the data be associated with an error.

Index

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 

A Sentry SDK for Racket
API Stability
Core API
current-sentry
current-sentry-user
Introduction
make-sentry
make-sentry-user
Quickstart
Reference
sentry
sentry-capture-exception!
sentry-user?
sentry?
Users