Introduce raven_dart, a Dart client for Sentry

You can become a serverless blackbelt. Enrol to my 4-week online workshop Production-Ready Serverless and gain hands-on experience building something from scratch using serverless technologies. At the end of the workshop, you should have a broader view of the challenges you will face as your serverless architecture matures and expands. You should also have a firm grasp on when serverless is a good fit for your system as well as common pitfalls you need to avoid. Sign up now and get 15% discount with the code yanprs15!

Since I’ve been experimenting with Sentry and hacking around in Dart again lately, so what better way is there to combine these two activities than to write a Dart client for Sentry?

That said, there is already a Javascript client library for Sentry, which via the dart:js library you can probably save yourself some code by writing a wrapper around the Javascript library instead. But I chose to write the client from scratch because:

  1. it’s more fun
  2. you can take advantage of Dart’s support for static type checking
  3. you can make use of Dart’s isolates (think F# mailbox or Erlang processes, isolates is Dart’s implementation of Carl Hewitt’s actor model) to abstract over making concurrent requests and handling retries, etc.
  4. wrapping the Javascript library means hard dependency on the Javascript library being present, which means you won’t be able to use it on the server side
  5. it’s more fun!


Update 05/07/2014 : I had previously stated that raven-js had dependencies on jQuery, ember, etc. that was incorrect. As they were in fact raven-js plugins for those frameworks (as stated in its Plugins documentation page here) and the raven-js itself doesn’t have any dependencies.


And the result is a small (~600 LOC) Dart library called raven_dart, that allows you to capture generic messages or exceptions as events in Sentry. The most basic usage would look like this:

Operational params can be used to customize the behaviour of captureMessage and captureException, such as adding tags, or other metadata to go along with the events.

Following the official guidelines on writing a Sentry client, the library supports:

  • DSN configuration via constructor argument
    • null means disabled
  • Graceful failure handling
    • fallback to logging to console when Sentry is disabled
    • retry on error (except for HTTP status codes 400, 401, 403, and 503)
    • configurable max no. of retries
    • exponential delay when retrying
    • temporarily disable if Sentry is unavailable (503)
  • Support for tagging
    • common tags can be provided in the client constructor
    • additional tags are supplied for each event
    • when common and event-specific tags overlap, both are sent as part of the event
  • Non-blocking event submission
    • events are sent to available isolates in round-robin fashion, whom then process them asynchronously and concurrently
    • configurable level of concurrency per core which determines number of isolates running at the same time
  • Basic data sanitization/scrubbing
    • credit card number-like fields are scrubbed
    • Sentry key and secrets are scrubbed
    • Values that look like passwords or secrets are scrubbed


Please give it a try and let me know what you think, if you find any bugs or have feedbacks in general, feel free to add them to the issues page.


Related Links

raven_dart homepage

raven_dart on

Libraries for C# and F# for easier integration with Sentry

Emulating F#’s discriminated unions (aka algebraic data types) in Dart

Emulating enums in Dart

Takeaways from Hewitt, Meijer and Szyperski’s talk on the Actor model

Liked this article? Support me on Patreon and get direct help from me via a private Slack channel or 1-2-1 mentoring.
Subscribe to my newsletter

Hi, I’m Yan. I’m an AWS Serverless Hero and I help companies go faster for less by adopting serverless technologies successfully.

Are you struggling with serverless or need guidance on best practices? Do you want someone to review your architecture and help you avoid costly mistakes down the line? Whatever the case, I’m here to help.

Hire me.

Skill up your serverless game with this hands-on workshop.

My 4-week Production-Ready Serverless online workshop is back!

This course takes you through building a production-ready serverless web application from testing, deployment, security, all the way through to observability. The motivation for this course is to give you hands-on experience building something with serverless technologies while giving you a broader view of the challenges you will face as the architecture matures and expands.

We will start at the basics and give you a firm introduction to Lambda and all the relevant concepts and service features (including the latest announcements in 2020). And then gradually ramping up and cover a wide array of topics such as API security, testing strategies, CI/CD, secret management, and operational best practices for monitoring and troubleshooting.

If you enrol now you can also get 15% OFF with the promo code “yanprs15”.

Enrol now and SAVE 15%.

Check out my new podcast Real-World Serverless where I talk with engineers who are building amazing things with serverless technologies and discuss the real-world use cases and challenges they face. If you’re interested in what people are actually doing with serverless and what it’s really like to be working with serverless day-to-day, then this is the podcast for you.

Check out my new course, Learn you some Lambda best practice for great good! In this course, you will learn best practices for working with AWS Lambda in terms of performance, cost, security, scalability, resilience and observability. We will also cover latest features from re:Invent 2019 such as Provisioned Concurrency and Lambda Destinations. Enrol now and start learning!

Check out my video course, Complete Guide to AWS Step Functions. In this course, we’ll cover everything you need to know to use AWS Step Functions service effectively. There is something for everyone from beginners to more advanced users looking for design patterns and best practices. Enrol now and start learning!