Hermann  Frami

Hermann Frami


Serverless Sentry Plugin

⚡️ Serverless Sentry Plugin    


This Serverless plugin simplifies the integration of Sentry with the popular Serverless Framework and AWS Lambda.

Currently, we support Lambda Runtimes for Node.js 12, 14, and 16 for AWS Lambda. Other platforms can be added by providing a respective integration library. Pull Requests are welcome!

The serverless-sentry-plugin and serverless-sentry-lib libraries are not affiliated with either Functional Software Inc., Sentry, Serverless or Amazon Web Services but developed independently and in my spare time.


  • Easy to use. Promised 🤞
  • Integrates with Serverless Framework as well as the AWS Serverless Application Model for AWS Lambda (though no use of any framework is required).
  • Wraps your Node.js code with Sentry error capturing.
  • Forwards any errors returned by your AWS Lambda function to Sentry.
  • Warn if your code is about to hit the execution timeout limit.
  • Warn if your Lambda function is low on memory.
  • Reports unhandled promise rejections.
  • Reports uncaught exceptions.
  • Serverless, Sentry and as well as this library are all Open Source. Yay! 🎉
  • TypeScript support


Sentry integration splits into two components:

  1. This plugin, which simplifies installation with the Serverless Framework
  2. The serverless-sentry-lib, which performs the runtime monitoring and error reporting.

For a detailed overview of how to use the serverless-sentry-lib refer to its README.md.


Install the @sentry/node module as a production dependency (so it gets packaged together with your source code):

npm install --save @sentry/node

Install the serverless-sentry-lib as a production dependency as well:

npm install --save serverless-sentry-lib

Install this plugin as a development dependency (you don't want to package it with your release artifacts):

npm install --save-dev serverless-sentry

Check out the examples below on how to integrate it with your project by updating serverless.yml as well as your Lambda handler code.


The Serverless Sentry Plugin allows configuration of the library through the serverless.yml and will create release and deployment information for you (if wanted). This is the recommended way of using the serverless-sentry-lib library.

▶️ Step 1: Load the Plugin

The plugin determines your environment during deployment and adds the SENTRY_DSN environment variables to your Lambda function. All you need to do is to load the plugin and set the dsn configuration option as follows:

service: my-serverless-project
  # ...
  - serverless-sentry
    dsn: https://xxxx:yyyy@sentry.io/zzzz # URL provided by Sentry

▶️ Step 2: Wrap Your Function Handler Code

The actual reporting to Sentry happens in platform-specific libraries. Currently, only Node.js and Python are supported.

Each library provides a withSentry helper that acts as decorators around your original AWS Lambda handler code and is configured via this plugin or manually through environment variables.

For more details refer to the individual libraries' repositories:

Old, now unsupported libraries:


For maximum flexibility, this library is implemented as a wrapper around your original AWS Lambda handler code (your handler.js or similar function). The withSentry higher-order function adds error and exception handling and takes care of configuring the Sentry client automatically.

withSentry is pre-configured to reasonable defaults and doesn't need any configuration. It will automatically load and configure @sentry/node which needs to be installed as a peer dependency.

Original Lambda Handler Code:

exports.handler = async function (event, context) {
  console.log("EVENT: \n" + JSON.stringify(event, null, 2));
  return context.logStreamName;

New Lambda Handler Code Using withSentry For Sentry Reporting

const withSentry = require("serverless-sentry-lib"); // This helper library

exports.handler = withSentry(async function (event, context) {
  console.log("EVENT: \n" + JSON.stringify(event, null, 2));
  return context.logStreamName;

ES6 Module: Original Lambda Handler Code:

export async function handler(event, context) {
  console.log("EVENT: \n" + JSON.stringify(event, null, 2));
  return context.logStreamName;

ES6 Module: New Lambda Handler Code Using withSentry For Sentry Reporting

import withSentry from "serverless-sentry-lib"; // This helper library

export const handler = withSentry(async (event, context) => {
  console.log("EVENT: \n" + JSON.stringify(event, null, 2));
  return context.logStreamName;

Once your Lambda handler code is wrapped in withSentry, it will be extended with automatic error reporting. Whenever your Lambda handler sets an error response, the error is forwarded to Sentry with additional context information. For more details about the different configuration options available refer to the serverless-sentry-lib documentation.

Plugin Configuration Options

Configure the Sentry plugin using the following options in your serverless.yml:

  • dsn - Your Sentry project's DSN URL (required)
  • enabled - Specifies whether this SDK should activate and send events to Sentry (defaults to true)
  • environment - Explicitly set the Sentry environment (defaults to the Serverless stage)

Sentry API access

In order for some features such as releases and deployments to work, you need to grant API access to this plugin by setting the following options:

  • organization - Organization name
  • project - Project name
  • authToken - API authentication token with project:write access

👉 Important: You need to make sure you’re using Auth Tokens not API Keys, which are deprecated.


Releases are used by Sentry to provide you with additional context when determining the cause of an issue. The plugin can automatically create releases for you and tag all messages accordingly. To find out more about releases in Sentry, refer to the official documentation.

In order to enable release tagging, you need to set the release option in your serverless.yml:

    dsn: https://xxxx:yyyy@sentry.io/zzzz
    organization: my-sentry-organziation
    project: my-sentry-project
    authToken: my-sentry-api-key
      version: <RELEASE VERSION>
        - repository: <REPOSITORY NAME>
          commit: <COMMIT HASH>
          previousCommit: <COMMIT HASH>

version - Set the release version used in Sentry. Use any of the below values:

  • git - Uses the current git commit hash or tag as release identifier.
  • random - Generates a random release during deployment.
  • true - First tries to determine the release via git and falls back to random if Git is not available.
  • false - Disable release versioning.
  • any fixed string - Use a fixed string for the release. Serverless variables are allowed.

refs - If you have set up Sentry to collect commit data, you can use commit refs to associate your commits with your Sentry releases. Refer to the Sentry Documentation for details about how to use commit refs. If you set your version to git (or true), the refs options are populated automatically and don't need to be set.

👉 Tip {"refs":["Invalid repository names: xxxxx/yyyyyyy"]}: If your repository provider is not supported by Sentry (currently only GitHub or Gitlab with Sentry Integrations) you have the following options:

  1. set refs: false, this will not automatically population the refs but also dismisses your commit id as version
  2. set refs: true and version: true to populate the version with the commit short id

If you don't specify any refs, you can also use the short notation for release and simply set it to the desired release version as follows:

    dsn: https://xxxx:yyyy@sentry.io/zzzz
    release: <RELEASE VERSION>

If you don't need or want the plugin to create releases and deployments, you can omit the authToken, organization and project options. Messages and exceptions sent by your Lambda functions will still be tagged with the release version and show up grouped in Sentry nonetheless.

👉 Pro Tip: The possibility to use a fixed string in combination with Serverless variables allows you to inject your release version through the command line, e.g. when running on your continuous integration machine.

    dsn: https://xxxx:yyyy@sentry.io/zzzz
    organization: my-sentry-organziation
    project: my-sentry-project
    authToken: my-sentry-api-key
      version: ${opt:sentryVersion}
        - repository: ${opt:sentryRepository}
          commit: ${opt:sentryCommit}

And then deploy your project using the command-line options from above:

sls deploy --sentryVersion 1.0.0 --sentryRepository foo/bar --sentryCommit 2da95dfb

👉 Tip when using Sentry with multiple projects: Releases in Sentry are specific to the organization and can span multiple projects. Take this in consideration when choosing a version name. If your version applies to the current project only, you should prefix it with your project name.

If no option for release is provided, releases and deployments are disabled.

Source Maps

Sourcemap files can be uploaded to Sentry to display source files in the stack traces rather than the compiled versions. This only uploads existing files being output, you'll need to configure your bundling tool separately. You'll also need to have releases configured, see above.

Default options:

    sourceMaps: true

Add custom prefix (required if your app is not at the filesystem root)

      urlPrefix: /var/task

Enabling and Disabling Error Reporting Features

In addition, you can configure the Sentry error reporting on a service as well as a per-function level. For more details about the individual configuration options see the serverless-sentry-lib documentation.

  • autoBreadcrumbs - Automatically create breadcrumbs (see Sentry Raven docs, defaults to true)
  • filterLocal - Don't report errors from local environments (defaults to true)
  • captureErrors - Capture Lambda errors (defaults to true)
  • captureUnhandledRejections - Capture unhandled Promise rejections (defaults to true)
  • captureUncaughtException - Capture unhandled exceptions (defaults to true)
  • captureMemoryWarnings - Monitor memory usage (defaults to true)
  • captureTimeoutWarnings - Monitor execution timeouts (defaults to true)

Example Configuration

# serverless.yml
service: my-serverless-project
  # ...
  - serverless-sentry
    dsn: https://xxxx:yyyy@sentry.io/zzzz # URL provided by Sentry
    captureTimeoutWarnings: false # disable timeout warnings globally for all functions
    handler: Foo.handler
    description: Hello World
      captureErrors: false # Disable error capturing for this specific function only
      captureTimeoutWarnings: true # Turn timeout warnings back on
    handler: Bar.handler
    sentry: false # completely turn off Sentry reporting

Example: Configuring Sentry based on stage

In some cases, it might be desired to use a different Sentry configuration depending on the currently deployed stage. To make this work we can use a built-in Serverless variable resolutions trick:

# serverless.yml
  - serverless-sentry
      sentryDsn: ""
      sentryDsn: "https://xxxx:yyyy@sentry.io/zzzz" # URL provided by Sentry

    dsn: ${self:custom.config.${self:provider.stage}.sentryDsn, self:custom.config.default.sentryDsn}
    captureTimeoutWarnings: false # disable timeout warnings globally for all functions


No errors are reported in Sentry

Double-check the DSN settings in your serverless.yml and compare it with what Sentry shows you in your project settings under "Client Keys (DSN)". You need a URL in the following format - see the Sentry Quick Start:


Also, make sure to add the plugin to your plugins list in the serverless.yml:

  - serverless-sentry
    dsn: https://xxxx:yyyy@sentry.io/zzzz # URL provided by Sentry

The plugin doesn't create any releases or deployments

Make sure to set the authToken, organization as well as project options in your serverless.yml, and set release to a non-empty value as shown in the example below:

  - serverless-sentry
    dsn: https://xxxx:yyyy@sentry.io/zzzz # URL provided by Sentry
    organization: my-sentry-organziation
    project: my-sentry-project
    authToken: my-sentry-api-key
    release: git

I'm testing my Sentry integration locally but no errors or messages are reported

Check out the filterLocal configuration setting. If you test Sentry locally and want to make sure your messages are sent, set this flag to false. Once done testing, don't forget to switch it back to true as otherwise, you'll spam your Sentry projects with meaningless errors of local code changes.

Version History


  • Increased number of parallel uploads of source map artifacts for better performance.


  • Upload multiple source map artifacts in parallel for better performance.


  • Fix #63: Upload source maps serially to avoid running out of sockets.
  • Correctly disable uploading source maps if the config setting is false or unset.


  • Added support for uploading Source Maps to Sentry. Thanks to jonmast for the contribution.
  • Fixed an issue in the configuration validation. Thanks to DonaldoLog for the fix.
  • Fixed an issue if using
  • Updated dependencies.


  • Explicitly check for enabled flag. Thanks to aaronbannin for the contribution.
  • Explicit peer dependency on Serverless
  • Updated dependencies minor versions; locked TypeScript to 4.4 for now


  • Added configuration validation. Serverless will now warn if you pass an invalid configuration value in custom.sentry.


  • Added captureUncaughtException configuration option. This already exists in serverless-sentry-lib but was never exposed in the plugin.
  • Don't fail if SENTRY_DSN is not set but simply disable Sentry integration.


  • Support for deploying individual functions only (sls deploy -f MyFunction). Thanks to dominik-meissner!
  • Improved documentation. Thanks to aheissenberger
  • Updated dependencies.


  • Fixed custom release names not being set. Thanks to botond-veress!


  • Fixed error when creating new Sentry releases. Thanks to dryror!


  • This version of serverless-sentry-plugin requires the use of serverless-sentry-lib v2.x.x
  • Rewrite using TypeScript. The use of TypeScript in your project is fully optional, but if you do, we got you covered!
  • Added new default uncaught exception handler.
  • Dropped support for Node.js 6 and 8. The only supported versions are Node.js 10 and 12.
  • Upgrade from Sentry SDK raven to the Unified Node.js SDK @sentry/node.
  • Simplified integration using withSentry higher-order function. Passing the Sentry instance is now optional.
  • Thank you @aheissenberger and @Vadorequest for their contributions to this release! 🤗


  • Fixed a compatibility issue with Serverless 1.28.0.


  • Support for sls invoke local. Thanks to sifrenette for his contribution.


  • ⚠️ Dropped support for Node 4.3. AWS deprecates Node 4.3 starting July 31, 2018.
  • Pair with serverless-sentry-lib v1.1.x.


  • Version falls back to git hash if no tag is set for the current head (#15).
  • Fixed reporting bugs in the local environment despite config telling otherwise (#17). This requires an update of serverless-sentry-lib as well!


  • Fixed an issue with creating random version numbers


  • Allow disabling Sentry for specific functions by settings sentry: false in the serverless.yml.
  • Added support for the Serverless Offline Plugin.


  • Fixed an issue with the plugin not being initialized properly when deploying an existing artifact.



  •  Bring back automatic instrumentation of the Lambda code during packaging
  •  Provide CLI commands to create releases and perform other operations in Sentry
  •  Ensure all exceptions and messages have been sent to Sentry before returning; see #338.


That you for supporting me and my projects.

Author: Arabold
Source Code: https://github.com/arabold/serverless-sentry-plugin 
License: MIT license

#serverless #aws #sentry #lambda 

Serverless Sentry Plugin

Sentry Python: The Official Python SDK for Sentry.io

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us Check out our open positions

Official Sentry SDK for Python

This is the official Python SDK for Sentry

Getting Started


pip install --upgrade sentry-sdk


import sentry_sdk


    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production.


from sentry_sdk import capture_message
capture_message("Hello World")  # Will create an event in Sentry.

raise ValueError()  # Will also create an event in Sentry.


(If you want to create a new integration have a look at the Adding a new integration checklist.)

Migrate From sentry-raven

The old raven-python client has entered maintenance mode and was moved here.

If you're using raven-python, we recommend you to migrate to this new SDK. You can find the benefits of migrating and how to do it in our migration guide.

Contributing to the SDK

Please refer to CONTRIBUTING.md.

Getting help/support

If you need help setting up or configuring the Python SDK (or anything else in the Sentry universe) please head over to the Sentry Community on Discord. There is a ton of great people in our Discord community ready to help you!


Licensed under the BSD license, see LICENSE

Author: getsentry
Source Code: https://github.com/getsentry/sentry-python
License: BSD-2-Clause License

#python #sentry 

Sentry Python: The Official Python SDK for Sentry.io
Python  Library

Python Library


Raven Python: The Legacy Python Client for Sentry

Deprecated for sentry-sdk package

Raven is deprecated in favor of Sentry-Python.

Feature development and most bugfixes happen exclusively there, as Raven is in maintenance mode.

Raven - Sentry for Python

Raven is the official legacy Python client for Sentry, officially supports Python 2.6–2.7 & 3.3–3.7, and runs on PyPy and Google App Engine.

It tracks errors and exceptions that happen during the execution of your application and provides instant notification with detailed information needed to prioritize, identify, reproduce and fix each issue.

It provides full out-of-the-box support for many of the popular python frameworks, including Django, and Flask. Raven also includes drop-in support for any WSGI-compatible web application.

Your application doesn't live on the web? No problem! Raven is easy to use in any Python application.

For more information, see our Python Documentation for framework integrations and other goodies.


  • Automatically report (un)handled exceptions and errors
  • Send customized diagnostic data
  • Process and sanitize data before sending it over the network


It's really easy to get started with Raven. After you complete setting up a project in Sentry, you’ll be given a value which we call a DSN, or Data Source Name. You will need it to configure the client.

Install the latest package with pip and configure the client:

pip install raven --upgrade

Create a client and capture an example exception:

from raven import Client

client = Client('___DSN___')

    1 / 0
except ZeroDivisionError:

Raven Python is more than that however. Checkout our Python Documentation.


Raven will continue to be maintained for bugfixes and contributions are more than welcome! New features should only go into the new sentry-python SDK.

There are many ways to contribute:


Not using Python? Check out our SDKs for other platforms.

Download Details:
Author: getsentry
Source Code: https://github.com/getsentry/raven-python
License: BSD-3-Clause License

#python #raven

Raven Python: The Legacy Python Client for Sentry

Install & Configure Sentry's APM to Performance Monitoring AWS Lambda

Amazon Web Services (AWS) Lambda is a usage-based computing infrastructure service that can execute Python 3 code. One of the challenges of this environment is ensuring efficient performance of your Lambda Functions. Application performance monitoring (APM) is particularly useful in these situations because you are billed based on how long you use the resources.

#aws #lambda #sentry 

Install & Configure Sentry's APM to Performance Monitoring AWS Lambda

Sentry SDK for Dart and Flutter

Sentry SDK for Dart .Pure Dart SDK used by any Dart application like AngularDart, CLI and Server.


For Flutter applications there's sentry_flutter which builds on top of this package. That will give you native crash support (for Android and iOS), release health, offline caching and more.


Sign up for a Sentry.io account and get a DSN at http://sentry.io.

Follow the installing instructions on pub.dev.

Initialize the Sentry SDK using the DSN issued by Sentry.io:

import 'package:sentry/sentry.dart';

Future<void> main() async {
  await Sentry.init(
    (options) {
      options.dsn = 'https://example@sentry.io/example';
    appRunner: initApp, // Init your App.

void initApp() {
  // your app code

Or, if you want to run your app in your own error zone [runZonedGuarded]:

import 'dart:async';

import 'package:sentry/sentry.dart';

Future<void> main() async {
  runZonedGuarded(() async {
    await Sentry.init(
      (options) {
        options.dsn = 'https://example@sentry.io/example';

    // Init your App.
  }, (exception, stackTrace) async {
    await Sentry.captureException(exception, stackTrace: stackTrace);

void initApp() {
  // your app code

Breadcrumbs for HTTP Requests

The SentryHttpClient can be used as a standalone client like this:

import 'package:sentry/sentry.dart';

var client = SentryHttpClient();
try {
 var uriResponse = await client.post('https://example.com/whatsit/create',
     body: {'name': 'doodle', 'color': 'blue'});
 print(await client.get(uriResponse.bodyFields['uri']));
} finally {

The SentryHttpClient can also be used as a wrapper for your own HTTP Client:

import 'package:sentry/sentry.dart';
import 'package:http/http.dart' as http;

final myClient = http.Client();

var client = SentryHttpClient(client: myClient);
try {
var uriResponse = await client.post('https://example.com/whatsit/create',
     body: {'name': 'doodle', 'color': 'blue'});
 print(await client.get(uriResponse.bodyFields['uri']));
} finally {

Tips for catching errors

  • Use a try/catch block.
  • Use a catchError block for Futures, examples on dart.dev.
  • The SDK already runs your callback on an error handler, e.g. using runZonedGuarded, events caught by the runZonedGuarded are captured automatically.
  • Current Isolate errors which is the equivalent of a main or UI thread, are captured automatically (Only for non-Web Apps).
  • For your own Isolates, add an Error Listener and call Sentry.captureException.


Use this package as a library

Depend on it

Run this command:

With Dart:

 $ dart pub add sentry

With Flutter:

 $ flutter pub add sentry

This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):

  sentry: ^5.1.0

Alternatively, your editor might support dart pub get or flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:sentry/sentry.dart'; 


// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:sentry/sentry.dart';

import 'event_example.dart';

/// Sends a test exception report to Sentry.io using this Dart client.
Future<void> main() async {
  // ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
  const dsn =

  SentryEvent? processTagEvent(SentryEvent event, {dynamic hint}) =>
      event..tags?.addAll({'page-locale': 'en-us'});

  await Sentry.init(
    (options) => options
      ..dsn = dsn
      ..debug = true
      ..sendDefaultPii = true
    appRunner: runApp,

Future<void> runApp() async {
  print('\nReporting a complete event example: ');

      message: 'Authenticated user',
      category: 'auth',
      type: 'debug',
      data: {
        'admin': true,
        'permissions': [1, 2, 3]

  Sentry.configureScope((scope) {
      ..user = SentryUser(
        id: '800',
        username: 'first-user',
        email: 'first@user.lan',
        // ipAddress: '', sendDefaultPii feature is enabled
        extras: <String, String>{'first-sign-in': '2020-01-01'},
      // ..fingerprint = ['example-dart'], fingerprint forces events to group together
      ..transaction = '/example/app'
      ..level = SentryLevel.warning
      ..setTag('build', '579')
      ..setExtra('company-name', 'Dart Inc');

  // Sends a full Sentry event payload to show the different parts of the UI.
  final sentryId = await Sentry.captureEvent(event);

  print('Capture event result : SentryId : $sentryId');

  print('\nCapture message: ');

  // Sends a full Sentry event payload to show the different parts of the UI.
  final messageSentryId = await Sentry.captureMessage(
    'Message 1',
    level: SentryLevel.warning,
    template: 'Message %s',
    params: ['1'],

  print('Capture message result : SentryId : $messageSentryId');

  try {
    await loadConfig();
  } catch (error, stackTrace) {
    print('\nReporting the following stack trace: ');
    final sentryId = await Sentry.captureException(
      stackTrace: stackTrace,

    print('Capture exception result : SentryId : $sentryId');

  // capture unhandled error
  await loadConfig();

Future<void> loadConfig() async {
  await parseConfig();

Future<void> parseConfig() async {
  await decode();

Future<void> decode() async {
  throw StateError('This is a test error');

#flutter  #dart #sentry 

Sentry SDK for Dart and Flutter

Self-Hosted Deployment of Sentry over AWS

Hello Readers. This will be a blog series on Self-hosted Sentry deployment over AWS. In the 1st blog of this series, I’ll be deploying a self-hosted Sentry server. Before starting up with deployment, let’s first understand what Sentry is and what does it provide.

What is Sentry?

Sentry is a service that helps you monitor and fix crashes in real-time. It helps in tracking errors and also provide with information to reproduce the issue and fix crashes. Apart from this, it also provides insights into production deployments, all that in real-time. Some of its prominent features include

  • Consolidates similar error and make their resolution easy
  • Huge list of supported platforms.
  • Provide Hosted and Self Hosted service
  • Multiple integrations available including GitHub and Slack
  • Allow Email Notification and many more…

#aws #self-hosted sentry #sentry #sentry deployment

Self-Hosted Deployment of Sentry over AWS