Comments (5)
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.
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:
- SENTRY_DSN
- SENTRY_ENVIRONMENT
- SENTRY_RELEASE
- SENTRY_AUTO_BREADCRUMBS
- SENTRY_FILTER_LOCAL
- SENTRY_CAPTURE_ERRORS
- etc. (see https://github.com/arabold/serverless-sentry-lib#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.
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.
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.
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)
- Create release failing on v2.0.0 HOT 2
- Cannot catch unhandled promise rejections HOT 8
- Add support for filtering events HOT 1
- READ.me file needs to be modified
- Any progress on uploading source maps? HOT 2
- Differences between this and official @sentry/serverless package HOT 2
- Add enable config
- Missing schema for `functions[].sentry` properties
- Serverless deployment fails with "fatal: No names found, cannot describe anything." HOT 23
- Plugin defines a validation schema that is invalid HOT 12
- Sentry: Error uploading sourcemap file - Error: connect EADDRNOTAVAIL 35.188.42.15:443 - Local HOT 27
- Repository name capturing from remote is wrong HOT 4
- Uploading source map doesn't work when deploying function only HOT 1
- Function Timeouts lack of information HOT 2
- Data scrubbing/Trace sampling feature request HOT 1
- [bug] [regression] Error: Sentry: Error deploying release - Error: Too Many Requests HOT 4
- Add support for @sentry/node v7
- enable CaptureConsole as an option
- Uploading source maps to sentry when using serverless-plugin-typescript
- Add Custom Tags
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-sentry-plugin.