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

Exceptions from AWS Lambda not making it to Sentry project

Open dr3x opened this issue 1 year ago • 3 comments

Package

Sentry.AspNetCore

.NET Flavor

.NET Core

.NET Version

6.0.6

OS

Other

SDK Version

Assembly Sentry, Version=3.20.1.0

Self-Hosted Sentry Version

No response

Steps to Reproduce

  1. Initialization
protected override void Init(IWebHostBuilder builder)
{
  builder.UseSentry(o =>
      {
          o.Dsn = sentryDsn;
          o.Debug = true;
          o.FlushOnCompletedRequest = true;
          o.FlushTimeout = TimeSpan.FromSeconds(sentryFlushTimeout);
          o.TracesSampleRate = 1.0;
          o.ConfigureScope(scope =>
          {
              scope.SetTag("lambda", _sentryTag);
          });
      });

    builder.UseStartup<Startup>();
}
  1. Capture Event
protected Guid? CaptureEvent(Exception? ex)
{
    return Sentry.SentrySdk.CaptureEvent(new Sentry.SentryEvent(ex));
}
  1. Cloudwatch log shows these entries in the event of an exception:
2022-07-28T14:38:46.720Z	5619f8f9-...	[Information] Sentry.ISentryClient: Capturing event. 
2022-07-28T14:38:47.400Z	5619f8f9-...	[Information] Sentry.ISentryClient: Envelope queued up: 'd498d...' 

Expected Result

Expect to see the exceptions captured in the Sentry project, not seeing them.

Am seeing some events captured from previous days so I know Sentry is at least intermittently functional.

Currently adding tagging, should see the exception being tagged.

Actual Result

Have exceptions in the project from 2 days ago but not today when I triggered the error.

dr3x avatar Jul 28 '22 15:07 dr3x

I'll take another look. Thanks for reporting.

mattjohnsonpint avatar Jul 28 '22 21:07 mattjohnsonpint

Hi @mattjohnsonpint , any more info on this? Is there any more logging / debugging I can do to troubleshoot? Thanks!

dr3x avatar Aug 08 '22 12:08 dr3x

Sorry, been swamped - but I will look again soon. Thanks for the reminder.

mattjohnsonpint avatar Aug 10 '22 21:08 mattjohnsonpint

@mattjohnsonpint - more info that might be helpful - Seems that the Sentry client is arbitrarily exiting before the lambda does:

2022-08-15T15:20:40.655Z	febe7822-14d9-48f9-a8c9-02c204de867d	
[Information] Sentry.ISentryClient: Shutdown token triggered. Time to exit. #1 in queue. 

When the exceptions are successfully making it over then you see something like this:

2022-08-15T12:13:02.136Z	d7a84002-9c82-446f-a0b1-53d05cce481a	
[Information] Sentry.ISentryClient: Envelope 'd5a90b...' successfully received by Sentry.

In either case, the entry is preceded by these two log entries consistently: [Information] Sentry.ISentryClient: Capturing event.

[Information] Sentry.ISentryClient: Envelope queued up: 'd5a90b...'

dr3x avatar Aug 15 '22 15:08 dr3x

@dr3x - could I get the whole block please? Everything logged from sentry for a single function request including the shutdown, with timestamps visible if possible. You can redact anything sensitive. Thanks.

mattjohnsonpint avatar Aug 15 '22 19:08 mattjohnsonpint

@mattjohnsonpint any more info on this from the logs I sent? Thanks

dr3x avatar Aug 31 '22 14:08 dr3x

I'm sorry, but after spending several more hours trying to reproduce this, I am unable. In all cases - events make it to sentry fine. I never get the Shutdown token triggered. Time to exit. message.

If you can create a repro, I'll investigate further. But at this point I'm at a loss.

I would need a complete repro - meaning a dotnet lambda app that I can compile and deploy to AWS that has the issue. The MRE guidance from Stack Overflow would be useful to follow.

Closing for now, but I'll re-open if you are able to provide a complete repro. Thanks.

mattjohnsonpint avatar Sep 02 '22 01:09 mattjohnsonpint

Thanks @mattjohnsonpint I'll work on getting you a MRE to reproduce

dr3x avatar Sep 02 '22 15:09 dr3x