No message showing up in Sentry with Zappa (no Flask)
See original GitHub issueEnv:
- Zappa running on Lambda
- This is a monorepo also using flask, but Flask is not deployed with AWS Lambda + API Gateway.
raven
working fine, trying to migrate tosentry-python
Other seemingly related issues:
Code (simplified):
lib/sentry.py
import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
sentry_sdk.init(
config.SENTRY_DSN,
debug=True,
integrations=[AwsLambdaIntegration()],
release=config.BUILD,
)
task/health.py
from zappa.async import task
@task
def send_sentry_message(): # pragma: no cover
sentry_sdk.capture_message("Test message from lambda worker")
try:
raise ExceptionTest("Fake exception to test exception handling in lambda worker")
except Exception:
sentry_sdk.capture_exception()
When I run send_sentry_message
, nothing shows up in Sentry.
raven
works fine
I have a raven
setup and a sentry-sdk
running alongside. Messages sent by raven
work fine, with the following configuration:
# in lib/sentry
from raven import Client
from raven.transport.http import HTTPTransport
from api.lib import config
client = Client(
dsn=config.SENTRY_DSN_WITH_SECRET_DEPRECATED,
processors=("raven.processors.SanitizePasswordsProcessor",),
release=config.BUILD,
raise_send_errors=True,
transport=HTTPTransport,
)
debug logs
With debug=True
, the logs look like this:
START RequestId: e050849e-0ec5-11e9-a95b-13339e6cd40a Version: $LATEST
Instancing..
[INFO] 2019-01-02T19:37:56.235Z e050849e-0ec5-11e9-a95b-13339e6cd40a Detected environment to be AWS Lambda. Using synchronous HTTP transport.
[sentry] DEBUG: Setting up integrations (with default = True)
[DEBUG] 2019-01-02T19:37:56.296Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up integrations (with default = True)
[sentry] DEBUG: Setting up previously not enabled integration aws_lambda
[DEBUG] 2019-01-02T19:37:56.330Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration aws_lambda
[sentry] DEBUG: Setting up previously not enabled integration logging
[DEBUG] 2019-01-02T19:37:56.330Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration logging
[sentry] DEBUG: Setting up previously not enabled integration stdlib
[DEBUG] 2019-01-02T19:37:56.330Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration stdlib
[sentry] DEBUG: Setting up previously not enabled integration excepthook
[DEBUG] 2019-01-02T19:37:56.330Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration excepthook
[sentry] DEBUG: Setting up previously not enabled integration dedupe
[DEBUG] 2019-01-02T19:37:56.331Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration dedupe
[sentry] DEBUG: Setting up previously not enabled integration atexit
[DEBUG] 2019-01-02T19:37:56.331Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration atexit
[sentry] DEBUG: Setting up previously not enabled integration modules
[DEBUG] 2019-01-02T19:37:56.331Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration modules
[sentry] DEBUG: Setting up previously not enabled integration argv
[DEBUG] 2019-01-02T19:37:56.331Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration argv
[sentry] DEBUG: Enabling integration aws_lambda
[DEBUG] 2019-01-02T19:37:56.331Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration aws_lambda
[sentry] DEBUG: Enabling integration logging
[DEBUG] 2019-01-02T19:37:56.331Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration logging
[sentry] DEBUG: Enabling integration stdlib
[DEBUG] 2019-01-02T19:37:56.331Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration stdlib
[sentry] DEBUG: Enabling integration excepthook
[DEBUG] 2019-01-02T19:37:56.331Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration excepthook
[sentry] DEBUG: Enabling integration dedupe
[DEBUG] 2019-01-02T19:37:56.332Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration dedupe
[sentry] DEBUG: Enabling integration atexit
[DEBUG] 2019-01-02T19:37:56.332Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration atexit
[sentry] DEBUG: Enabling integration modules
[DEBUG] 2019-01-02T19:37:56.332Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration modules
[sentry] DEBUG: Enabling integration argv
[DEBUG] 2019-01-02T19:37:56.332Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration argv
[INFO] 2019-01-02T19:37:56.351Z e050849e-0ec5-11e9-a95b-13339e6cd40a Found credentials in environment variables.
[sentry] DEBUG: Setting up integrations (with default = True)
[DEBUG] 2019-01-02T19:37:56.509Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up integrations (with default = True)
[sentry] DEBUG: Setting up previously not enabled integration flask
[DEBUG] 2019-01-02T19:37:56.509Z e050849e-0ec5-11e9-a95b-13339e6cd40a Setting up previously not enabled integration flask
[sentry] DEBUG: Enabling integration flask
[DEBUG] 2019-01-02T19:37:56.509Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration flask
[sentry] DEBUG: Enabling integration logging
[DEBUG] 2019-01-02T19:37:56.509Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration logging
[sentry] DEBUG: Enabling integration stdlib
[DEBUG] 2019-01-02T19:37:56.509Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration stdlib
[sentry] DEBUG: Enabling integration excepthook
[DEBUG] 2019-01-02T19:37:56.509Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration excepthook
[sentry] DEBUG: Enabling integration dedupe
[DEBUG] 2019-01-02T19:37:56.510Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration dedupe
[sentry] DEBUG: Enabling integration atexit
[DEBUG] 2019-01-02T19:37:56.510Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration atexit
[sentry] DEBUG: Enabling integration modules
[DEBUG] 2019-01-02T19:37:56.510Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration modules
[sentry] DEBUG: Enabling integration argv
[DEBUG] 2019-01-02T19:37:56.510Z e050849e-0ec5-11e9-a95b-13339e6cd40a Enabling integration argv
[INFO] 2019-01-02T19:37:56.650Z e050849e-0ec5-11e9-a95b-13339e6cd40a
{
"status": "starting",
"name": "send_sentry_message",
"event": "lambda task",
"logger": "api.task.base",
"level": "info",
"timestamp": "2019-01-02T19:37:56.649991Z"
}
[INFO] 2019-01-02T19:37:56.672Z e050849e-0ec5-11e9-a95b-13339e6cd40a
{
"status": "done",
"name": "send_sentry_message",
"event": "lambda task",
"logger": "api.task.base",
"level": "info",
"timestamp": "2019-01-02T19:37:56.672028Z"
}
Result of zappa.async.route_lambda_task:
null
END RequestId: e050849e-0ec5-11e9-a95b-13339e6cd40a
REPORT RequestId: e050849e-0ec5-11e9-a95b-13339e6cd40a Duration: 11075.88 ms Billed Duration: 11100 ms Memory Size: 512 MB Max Memory Used: 138 MB
The only thing I see is that it’s activating the flask plugin even though it’s not used in this context, but looking at the flask plugin code, it shouldn’t impact sending the message.
Happy to dig more based on your feedback.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Unable to report errors from Zappa - Integrations - #sentry
I am setting up Sentry for my Flask/Lambda and I am receiving the following tracebacks in my Zappa (Flask/Lambda) logs:
Read more >Sentry logging via Flask app - python - Stack Overflow
The problem is that the logging entries aren't sent to Sentry as they happen. Instead they seem to be 'saved up' and only...
Read more >zappa-mathking - Python Package Health Analysis | Snyk
AWS handles the horizontal scaling automatically, so no requests ever ... Similarly, you can do the inverse and only show non-HTTP events and...
Read more >Composition of views and models | Flask Framework Cookbook ...
The models file, flask_app/my_app/hello/models.py , has a non-persistent key-value store, as follows: MESSAGES = { 'default': 'Hello to the World of Flask!'
Read more >@jneves - python in a cloud world
If it's your main project directory and your project is not just a package, no. If the directory is a package, yes. If...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool, this worked:
As this issue is resolved in the comments and everyone is happy, I will close this issue. Thanks everyone for your help!