Skip to content

Sessions on a crashed app not closed as such #1844

Closed as not planned
Closed as not planned

Description

Package

Sentry

.NET Flavor

.NET

.NET Version

6.0.6

OS

macOS

SDK Version

3.20.1

Steps to Reproduce

using Sentry;

using var _ = SentrySdk.Init(o =>
{
    o.Dsn = "...";
    o.Debug = true;
    o.TracesSampleRate = 1.0;
    o.IsGlobalModeEnabled = true;
    o.AutoSessionTracking = true;
#if DEBUG
    o.Environment = "development";
#endif
});

var tran = SentrySdk.StartTransaction("asd", "asd.asd");
// Forgot about this. Not a great API
SentrySdk.ConfigureScope(s => s.Transaction = tran);

try
{ 
        throw new Exception("Can't find summary line. Page changed?");
}
catch (Exception e)
{
 // Exception is only captured and tied to the transaction if I explicitly capture it here 
    throw; // When I rethrow, the session ends as success (no session update it sent, only the initial healthy one)
}

If I remove the using var _ =, so the SDK doesn't dispose anymore and everything works as expected

Expected Result

If a process crashes, the final session update envelope should have status=crashed.
If a transaction was bound to the scope, the status of that transaction should be some type of error. Since an exception bubbled out and crashed the process.

  • Session marked as crashed (aka: status=crashed)
  • The event that crashed the app captured. The error event also links to transaction. That's the default behavior, you can see that by capturing an event (e.g: CaptureMessage) while a transaction is bound to the scope.
  • The transaction status is InternalError (or other failure status that makes more sense). And links to the error

Actual Result

Only a transaction was captured and its status was unknown. If no Status is set to the transaction, unknown is what the server infers.

Additional problem (but unrelated to the session) the installationid is getting installed on (/Users/bruno/.local/share/Sentry/4F084E9C0D55B08D0AAF5DD0615DF4A719A28E29).. This seems to me it'll be shared with any other CLI executed via dotnet. I believe a child directory should be created named after the main assembly. Or any other solution that makes these ids different "per app".

  Debug: Logging enabled with ConsoleDiagnosticLogger and min level: Debug
  Debug: Initializing Hub for Dsn: '..'.
  Debug: Using 'GzipBufferedRequestBodyHandler' body compression strategy with level Optimal.
  Debug: Starting BackgroundWorker.
  Debug: Registering integration: 'AutoSessionTrackingIntegration'.
  Debug: Attempting to recover persisted session from file.
  Debug: Persistence directory is not set, returning.
  Debug: BackgroundWorker Started.
  Debug: Created directory for installation ID file (/Users/bruno/.local/share/Sentry/4F084E9C0D55B08D0AAF5DD0615DF4A719A28E29).
  Debug: Resolved installation ID '7053cbc5-a5eb-481c-8a88-dc5df456df92'.
   Info: Started new session (SID: b7cc11af66a742df8e3019e40eed5bf7; DID: 7053cbc5-a5eb-481c-8a88-dc5df456df92).
  Debug: Persisting session (SID: 'b7cc11af66a742df8e3019e40eed5bf7') to a file.
  Debug: Persistence directory is not set, returning.
  Debug: Enqueuing envelope
   Info: Envelope queued up: ''
  Debug: Registering integration: 'AppDomainUnhandledExceptionIntegration'.
  Debug: Registering integration: 'AppDomainProcessExitIntegration'.
  Debug: Registering integration: 'TaskUnobservedTaskExceptionIntegration'.
  Debug: Registering integration: 'SentryDiagnosticListenerIntegration'.
  Debug: Configuring the scope.
  Debug: Envelope  handed off to transport. #1 in queue.
  Debug: Envelope '' sent successfully. Payload: {"sdk":{"name":"sentry.dotnet","version":"3.20.1"},"sent_at":"2022-08-07T17:42:39.187397+00:00"} {"type":"session","length":297} {"sid":"b7cc11af66a742df8e3019e40eed5bf7","did":"7053cbc5-a5eb-481c-8a88-dc5df456df92","init":true,"started":"2022-08-07T13:42:38.846525-04:00","timestamp":"2022-08-07T17:42:38.847454+00:00","seq":0,"duration":0,"errors":0,"attrs":{"release":"asd@1.0.0","environment":"development"}}
  Debug: De-queueing event
  Debug: Configuring the scope.
  Debug: Enqueuing envelope 22a5b79cf4cf4076b55ef16fa7cd8f56
   Info: Envelope queued up: '22a5b79cf4cf4076b55ef16fa7cd8f56'
   Info: Disposing the Hub.
  Debug: Tracking depth: 1.
  Debug: Envelope 22a5b79cf4cf4076b55ef16fa7cd8f56 handed off to transport. #1 in queue.
  Debug: Envelope '22a5b79cf4cf4076b55ef16fa7cd8f56' sent successfully. Payload: {"sdk":{"name":"sentry.dotnet","version":"3.20.1"},"event_id":"22a5b79cf4cf4076b55ef16fa7cd8f56","sent_at":"2022-08-07T17:42:39.34872+00:00"} {"type":"transaction","length":988} {"type":"transaction","event_id":"22a5b79cf4cf4076b55ef16fa7cd8f56","platform":"csharp","release":"asd@1.0.0","transaction":"crawl","start_timestamp":"2022-08-07T17:42:38.85351+00:00","timestamp":"2022-08-07T17:42:39.2768096+00:00","request":{},"contexts":{"trace":{"type":"trace","span_id":"e2f261a76bed46e6","trace_id":"2c8a687cbe7a4d538eef188a2ea2143b","op":"asd","status":"unknown_error"},"runtime":{"type":"runtime","name":".NET","version":"6.0.6","raw_description":".NET 6.0.6","identifier":"osx.12-x64"},"device":{"type":"device","boot_time":"2022-08-06T09:07:50.5696732+00:00"},"app":{"type":"app","app_start_time":"2022-08-07T17:42:38.381471+00:00"},"os":{"type":"os","raw_description":"Darwin 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64"}},"user":{},"environment":"development","sdk":{"packages":[{"name":"nuget:sentry.dotnet","version":"3.20.1"}],"name":"sentry.dotnet","version":"3.20.1"}}
  Debug: De-queueing event 22a5b79cf4cf4076b55ef16fa7cd8f56
  Debug: Signaling flush completed.
  Debug: Successfully flushed all events up to call to FlushAsync.
   Info: AppDomain process exited: Disposing SDK.
   Info: Disposing the Hub.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

BugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions