3.2Users
3.3Tracing
8.18
top
← prev up next →

Sentry SDKπŸ”— i

Bogdan Popa <bogdan@defn.io>

1IntroductionπŸ”— i

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

2QuickstartπŸ”— i

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)
(define client(make-sentry "https://key@sentry.io/12"))
(sentry-stop client)

3ReferenceπŸ”— i

(require sentry ) package: sentry-lib

3.1Core APIπŸ”— i

procedure

( event? v)boolean?

v:any/c
Returns #t when v is an event captured by sentry-capture-exception! .

Added in version 0.5 of package sentry-lib.

procedure

( sentry? v)boolean?

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

parameter

( current-sentry )(or/c #fsentry? )

(current-sentry client)void?
client:(or/c #fsentry? )
Stores the current Sentry client for use with sentry-capture-exception! .

procedure

( make-sentry dsn
[ #:samplersampler
#:backlogbacklog
#:releaserelease
#:environmentenvironment
#:connect-timeout-msconnect-timeout
#:send-timeout-mssend-timeout
#:max-breadcrumbsmax-breadcrumbs])sentry?
dsn:string?
sampler : (-> (or/c event? transaction? )(real-in 0.01.0))
= (lambda (_ )1.0)
release : (or/c #fnon-empty-string? )
= (getenv "SENTRY_RELEASE")
environment : (or/c #fnon-empty-string? )
= (getenv "SENTRY_ENVIRONMENT")
connect-timeout:exact-positive-integer? =5000
send-timeout:exact-positive-integer? =5000
max-breadcrumbs:exact-positive-integer? =50
Returns a Sentry client.

The #:backlog argument controls the size of the error queue. Events are dropped when the queue is full.

When the #:release argument is set, every event is tagged with the given value. Ditto for the #:environment argument.

The reutrned client logs messages to the 'sentry topic.

The #:sampler argument determines what chance an event has to be sent to the server. The default implementation samples 100% of all events.

Changed in version 0.5 of package sentry-lib: Added the #:sampler argument.

procedure

[ client
#:levellevel
#:timestamptimestamp
#:server-nameserver-name
#:environmentenvironment
#:releaserelease
#:requestrequest
#:tagstags
#:useruser])
(evt/c void? )
e:exn?
client:(or/c #fsentry? )=(current-sentry )
level:(or/c 'fatal'error'warning'info'debug)='error
timestamp:(or/c date*? moment? )=(current-utc-date)
server-name:(or/c #fnon-empty-string? )=#f
environment:(or/c #fnon-empty-string? )=#f
release:(or/c #fnon-empty-string? )=#f
request:(or/c #frequest? )=#f
Sends e to Sentry. Returns a synchronizable event that is ready for synchronization when the event leaves the queue, which means either that it has been sent to the Sentry API or that it has been dropped due to rate limits. When client is #f, all events are dropped.

procedure

( sentry-stop [client])void?

Waits for all pending events in client to be sent and then shuts down its event loop.

3.2UsersπŸ”— i

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.

procedure

( make-sentry-user #:idid
[ #:usernameusername
#:emailemail
#:ip-addressip-address
#:subscriptionsubscription])sentry-user?
username:(or/c #fnon-empty-string? )=#f
email:(or/c #fnon-empty-string? )=#f
ip-address:(or/c #fnon-empty-string? )=#f
subscription:(or/c #fnon-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.

3.3TracingπŸ”— i

A transaction tracks a set of spans and delivers them to Sentry when the transaction completes. A span measures and records information about a block of code.

procedure

( transaction? v)boolean?

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

Holds the current transaction. The call-with-transaction procedure automatically installs a transaction in this parameter.

procedure

proc
[ #:datadata
#:originorigin
#:sourcesource
#:trace-idtrace-id
#:parent-idparent-id
#:operationoperation
#:descriptiondescription
#:requestrequest])any
name:string?
data:(or/c #f(hash/c symbol? jsexpr? ))=#f
origin:symbol? ='manual
source:symbol? ='custom
trace-id:(or/c #fstring? )=#f
parent-id:(or/c #fstring? )=#f
operation:symbol? ='function
description:(or/c #fstring? )=#f
request:(or/c #fjsexpr? )=#f
Calls proc in the context of a transaction with the given name. When the call to proc finishes executing, the transaction is sent to the current-sentry client. If there is no current client, the transaction information is discarded at the end of the call.

The value passed to the name argument should follow the conventions defined for the value passed to the #:source argument. The supported #:source values can be found in Sentry’s Transaction Annotations documentation.

The #:trace-id and #:parent-id may be used to propagate distributed tracing ids to the new transaction. See Sentry’s documentation on the sentry-trace header for details. If not provided, and the call is nested within another transaction, then the parent transaction’s values are inherited. If there is no parent transaction, then new trace and span ids are generated automatically.

The #:operation should be one of the values listed in Sentry’s Span Operations documentation.

The #:description may be an arbitrary string describing the transaction in detail.

The #:request may be a jsexpr? conforming to the request interface.

Changed in version 0.6 of package sentry-lib: Added the #:origin and #:request arguments.

procedure

( span? v)boolean?

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

parameter

( current-span )(or/c #fspan? )

s:(or/c #fspan? )
Holds the current span. The call-with-span procedure automatically installs a span in this parameter.

procedure

[ #:operationoperation
#:descriptiondescription
#:originorigin
#:datadata])any
proc:(-> span? any )
operation:symbol? ='function
description:(or/c #fstring? )=#f
origin:symbol? ='manual
data:(or/c #f(hash/c symbol? jsexpr? ))=#f
Calls proc in the context of a span with the given #:operation and #:description. When the call to proc finishes executing, the span is registered with the surrounding transaction. If there is no surrounding transaction, the span is discarded at the end of the call.

The #:operation should be one of the values listed in Sentry’s Span Operations documentation.

The #:description may be an arbitrary string describing the operation in detail.

procedure

( get-span-id v)string?

Returns the id of the given transaction or span.

Returns the trace id of the given transaction or span.

procedure

( span-set! skv)void?

Sets k to v within s’s data payload.

3.3.1Database QueriesπŸ”— i

procedure

( trace-connectionc)connection?

Wraps all queries performed by c in a 'db.query span, recording the executed statement.

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /