Giter VIP home page Giter VIP logo

Comments (5)

kevgliss avatar kevgliss commented on May 27, 2024 1

FYI I have started this work here:
https://github.com/Netflix-Skunkworks/raven-python-lambda

Still very much a WIP. I also shamelessly stole a lot your documentation as it was so similar. Thanks for the guidance! Look forward using it in conjunction with serverless-sentry-plugin.

Cheers,
Kevin

from serverless-sentry-plugin.

arabold avatar arabold commented on May 27, 2024

Hi @kevgliss . Thanks for your interest. I really appreciate.

The plugin itself (this code here) does not need to be ported as it's working for all platforms running on AWS. There's an additional serverless-sentry-lib that integrates with the user's Node.js code. This lib needs to be ported to Python.

If you follow the Node.js documentation, the serverless-sentry-lib for Node needs to be added by the user to his project and loaded manually. It's a 3rd party dependency like any other. There's no magic for adding the library to your code base.

The plugin passes the serverless.yaml configuration options to the Lambda (and thus to the lib) via environment variables:

So basically what you have to do is to write a Python module that checks these environment variables, loads the official Python Raven module and configures it accordingly. Note that the variables are only set if they differ from their default values.

The Node.js library has some special tricks up its sleeve that are not necessary to be implemented in Python right away, but can be added over time:

  • The Lambda start is automatically logged using a breadcrumb
  • Check for local environment and forward only messages if deployed on Lambda: specifically check for IS_OFFLINE and IS_LOCAL here
  • Tracking and alerting on memory usage: monitor memory and alert once 75% of allocated memory used
  • Tracking and alerting on runtime: set a timeout to about 2/3 of the maximal runtime of the Lambda and alert if reached

Other features of the plugin, such as deployment notifications in Sentry, are available independently of the lib used.

Hope that helps. Let me know if any questions or issues arise.

from serverless-sentry-plugin.

arabold avatar arabold commented on May 27, 2024

You could even start to use the serverless-sentry-plugin without writing a dedicated Pyhton library first. If you simply check for the given environment variables in your code (specifically the SENTRY_* ones) you can do pretty much all you want by passing them to the Python Client: Set dsn to SENTRY_DSN, release to SENTRY_RELEASE, environment to SENTRY_ENVIRONMENT, etc. See https://docs.sentry.io/clients/python/advanced/#client-arguments for the full list of parameters accepted by the Sentry client.

In addition, for Node we're automatically setting a couple of Sentry tags based on the environment variables available:

{
  release: SENTRY_RELEASE,
  environment: SENTRY_ENVIRONMENT,
  tags: {
    lambda: AWS_LAMBDA_FUNCTION_NAME,
    version: AWS_LAMBDA_FUNCTION_VERSION,
    memory_size: AWS_LAMBDA_FUNCTION_MEMORY_SIZE,
    log_group: AWS_LAMBDA_LOG_GROUP_NAME,
    log_stream: AWS_LAMBDA_LOG_STREAM_NAME,
    service_name: SERVERLESS_SERVICE,
    stage: SERVERLESS_STAGE,
    alias: SERVERLESS_ALIAS,
    region: SERVERLESS_REGION || AWS_REGION
  }
}

The AWS_LAMBDA_* variables are set by the Lambda environment itself (might be different for Python?!), the SERVERLESS_* ones are optional and can be set by the user via the serverless.yaml. And finally the SENTRY_* environment variables are set by theserverless-sentry-plugin.

This should work right away. Then, if you have working code, it should be rather simple to extract the common functions into a dedicated library to share with the community.

from serverless-sentry-plugin.

kevgliss avatar kevgliss commented on May 27, 2024

Ah, that makes much more sense now. There are already quite a few integrations for raven-python that I can use as examples.

Once created I can simply use this plugin to layer in the necessary serverless environment variables.

Those tags look super useful, thanks!

from serverless-sentry-plugin.

arabold avatar arabold commented on May 27, 2024

Very cool! Let me know if you need anything. I'm gonna link the python lib here in the main repo, too, so people can find it in future.

from serverless-sentry-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.