sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Attach AWS serverless timeout warning logs to debug mode

Open Fwang36 opened this issue 2 years ago • 2 comments

Problem Statement

For the normal python sdk, we usually only output logging with debug=True, but with the AWSLambdaIntegration() the timeout warnings are logged regardless of whether debug is on or not.

Screenshot 2023-08-24 at 12 55 38 PM

We may want to keep it consistent and attach the serverless logs to debug mode as well.

Solution Brainstorm

Maybe either attach the logging to debug mode, or add an another option to the integration to output logs or not.

Fwang36 avatar Aug 24 '23 16:08 Fwang36

Hey @Fwang36 Thanks for reporting this!

One thing to consider: If people add the AWS Layer to their function (instrumenting their Lambda function without changing their code) they can not set the DEBUG=True flag, thus would never see the timeout warning.

antonpirker avatar Aug 29 '23 12:08 antonpirker

Maybe we should add an env var to the layer instrumentation to enable/disable the debug flag in sentry.init().

antonpirker avatar Aug 29 '23 12:08 antonpirker

As the users can set the timeout_warnings option I will close this issue.

antonpirker avatar Dec 11 '24 09:12 antonpirker

@antonpirker - Behavior will be unchanged?

DM1145 avatar Dec 11 '24 18:12 DM1145

@antonpirker - I agree that a single line with the warning should get written to the log, but I'd think that unless the debug flag is set, that should be the only line written there.

Current Logged Messages without Debug flag set:

Exception in thread Thread-1: Traceback (most recent call last): File "/var/lang/lib/python3.9/threading.py", line 980, in _bootstrap_inner self.run() File "/opt/python/sentry_sdk/integrations/threading.py", line 100, in run return _run_old_run_func() File "/opt/python/sentry_sdk/integrations/threading.py", line 95, in _run_old_run_func reraise(*_capture_exception()) File "/opt/python/sentry_sdk/utils.py", line 1690, in reraise raise value File "/opt/python/sentry_sdk/integrations/threading.py", line 93, in _run_old_run_func return old_run_func(self, *a, **kw) File "/opt/python/sentry_sdk/utils.py", line 1449, in run raise ServerlessTimeoutWarning( sentry_sdk.utils.ServerlessTimeoutWarning: WARNING : Function is expected to get timed out. Configured timeout duration = 5 seconds.

Expected Logged Messages without Debug flag set:

sentry_sdk.utils.ServerlessTimeoutWarning: WARNING : Function is expected to get timed out. Configured timeout duration = 5 seconds.

Should I reopen this ticket or create a new one?

DM1145 avatar Dec 13 '24 21:12 DM1145