sentry-dotnet
sentry-dotnet copied to clipboard
Start event not received when using `AutoStartSession`
Environment
Sentry.io / NuGet package 3.12.0 / .NET 6.0
Steps to Reproduce
- Create a sample project with
using (SentrySdk.Init(o =>
{
o.Dsn = "<ENTER_YOUR_DSN_HERE>";
o.AutoSessionTracking = true;
}))
{
Thread.Sleep(1000);
throw new Exception("Test");
}
- Go to the dashboard
- Observe there is no start event:

Workaround
If I explicitly start the session after the init:
using (SentrySdk.Init(o =>
{
o.Dsn = "<ENTER_YOUR_DSN_HERE>";
}))
{
SentrySdk.StartSession();
Thread.Sleep(1000);
throw new Exception("Test");
}
I do get the start event:

Hi jairbubbles, thank you for reporting this bug. The session is being created but the Starting Session breadcrumb is not shown.
The Sentry hub is not yet initialized when sending the "Starting Sentry Session" message thus the message doesn't appear on the breadcrumbs.
Hi @lucas-zimerman, do you mean it's just a visual bug?
Because when looking at the session times it was always 0 which lead me to investigate and found that bug.
using (SentrySdk.Init(o =>
{
o.Dsn = "<ENTER_YOUR_DSN_HERE>";
o.AutoSessionTracking = true;
o.Debug = true;
}))
{
Thread.Sleep(1000);
throw new Exception("Test");
}
If you enable the debug flag it should show that the event was ended as shown below
Info: Ended session (SID: ca4fc27b2dde44f58eef2ead04766e22; DID: ac9ea430-fe5d-4ea7-a37e-3d51a73c97c7) with status 'Crashed'.
And also it should show the envelope sent with both error and session together,
If it doesn't show that the session was created or sent, could you share the log created by enabling the Debug flag?
There seems to be a correct session in the envelope.
{"type":"session","length":311}
{"sid":"e15f74b3843b47139ff066304d4b7bb4","did":"4a54d37a-d8b6-4f72-976f-ae2923de90dc","init":false,"started":"2021-11-27T11:30:41.5591781+01:00","timestamp":"2021-11-27T10:30:42.5803918+00:00","seq":1,"duration":1,"errors":0,"status":"crashed","attrs":{"release":"[email protected]","environment":"production"}}
But there is also that mesage:
Debug: Failed to end session because there is none active.
I might have misunderstood the graph but it always showing me 0 ms for session duration:

I believe Sentry only takes healthy session durations into account. @matejminar might correct me here.
Thx @bruno-garcia, I sent a few healthy session on my test project and now I can see some numbers:

I sent two "1 second" sessions, I'm not sure how it's computed 🤔
Two 1 second sessions should result in a p50 of 1 second though. Assuming no other session made through for that release
So, is this a bug? @bruno-garcia
Looks like yes, this is a bug.
This issue is so old that it's hard to follow up on it and even the product changed in the meantime.
The session manager underwent some changes and I remember a fix regarding the Debug: Failed to end session because there is none active. so this might have fixed itself.
Please feel free to reopen this if it does still affect you.