Introduce raven_dart, a Dart client for Sentry

Since I’ve been exper­i­ment­ing with Sen­try and hack­ing around in Dart again late­ly, so what bet­ter way is there to com­bine these two activ­i­ties than to write a Dart client for Sen­try?

That said, there is already a Javascript client library for Sen­try, which via the dart:js library you can prob­a­bly save your­self some code by writ­ing a wrap­per around the Javascript library instead. But I chose to write the client from scratch because:

  1. it’s more fun
  2. you can take advan­tage of Dart’s sup­port for sta­t­ic type check­ing
  3. you can make use of Dart’s iso­lates (think F# mail­box or Erlang process­es, iso­lates is Dart’s imple­men­ta­tion of Carl Hewitt’s actor mod­el) to abstract over mak­ing con­cur­rent requests and han­dling retries, etc.
  4. wrap­ping the Javascript library means hard depen­den­cy on the Javascript library being present, which means you won’t be able to use it on the serv­er side
  5. it’s more fun!

 

Update 05/07/2014 : I had pre­vi­ous­ly stat­ed that raven-js had depen­den­cies on jQuery, ember, etc. that was incor­rect. As they were in fact raven-js plu­g­ins for those frame­works (as stat­ed in its Plu­g­ins doc­u­men­ta­tion page here) and the raven-js itself doesn’t have any depen­den­cies.

 

And the result is a small (~600 LOC) Dart library called raven_dart, that allows you to cap­ture gener­ic mes­sages or excep­tions as events in Sen­try. The most basic usage would look like this:

Oper­a­tional params can be used to cus­tomize the behav­iour of cap­tureMes­sage and cap­ture­Ex­cep­tion, such as adding tags, or oth­er meta­da­ta to go along with the events.

Fol­low­ing the offi­cial guide­lines on writ­ing a Sen­try client, the library sup­ports:

  • DSN con­fig­u­ra­tion via con­struc­tor argu­ment
    • null means dis­abled
  • Grace­ful fail­ure han­dling
    • fall­back to log­ging to con­sole when Sen­try is dis­abled
    • retry on error (except for HTTP sta­tus codes 400, 401, 403, and 503)
    • con­fig­urable max no. of retries
    • expo­nen­tial delay when retry­ing
    • tem­porar­i­ly dis­able if Sen­try is unavail­able (503)
  • Sup­port for tag­ging
    • com­mon tags can be pro­vid­ed in the client con­struc­tor
    • addi­tion­al tags are sup­plied for each event
    • when com­mon and event-spe­cif­ic tags over­lap, both are sent as part of the event
  • Non-block­ing event sub­mis­sion
    • events are sent to avail­able iso­lates in round-robin fash­ion, whom then process them asyn­chro­nous­ly and con­cur­rent­ly
    • con­fig­urable lev­el of con­cur­ren­cy per core which deter­mines num­ber of iso­lates run­ning at the same time
  • Basic data sanitization/scrubbing
    • cred­it card num­ber-like fields are scrubbed
    • Sen­try key and secrets are scrubbed
    • Val­ues that look like pass­words or secrets are scrubbed

 

Please give it a try and let me know what you think, if you find any bugs or have feed­backs in gen­er­al, feel free to add them to the issues page.

 

Related Links

raven_dart home­page

raven_dart on pub.dartlang.org

Libraries for C# and F# for eas­i­er inte­gra­tion with Sen­try

Emu­lat­ing F#’s dis­crim­i­nat­ed unions (aka alge­bra­ic data types) in Dart

Emu­lat­ing enums in Dart

Take­aways from Hewitt, Mei­jer and Szyperski’s talk on the Actor mod­el