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

when ProfilingIntegration is used memory and CPU usage increases significantly

Open aalirezamoradii opened this issue 1 year ago • 3 comments

Package

Sentry.AspNetCore

.NET Flavor

.NET

.NET Version

8.0.0

OS

Linux

SDK Version

4.13.0

Self-Hosted Sentry Version

24.10.0

Steps to Reproduce

in the .Net 8.0 (Microsoft.NET.Sdk.Web) Program.cs

var builder = WebApplication.CreateBuilder(args);
        
builder.WebHost.UseSentry(o =>
{
    o.AddIntegration(new ProfilingIntegration(TimeSpan.FromMilliseconds(500)));
    o.AddEntityFramework();
});

var app = builder.Build();

// other middlewares

app.UseSentryTracing();

// other middlewares

app.Run();

Expected Result

Without using o.AddIntegration(new ProfilingIntegration(TimeSpan.FromMilliseconds(500)));

Image

Actual Result

After using o.AddIntegration(new ProfilingIntegration(TimeSpan.FromMilliseconds(500)));

When start: Image

After 5 minutes: Image

aalirezamoradii avatar Nov 17 '24 12:11 aalirezamoradii

@vaind any ideas?

jamescrosswell avatar Nov 17 '24 22:11 jamescrosswell

Memory: From my previous testing (because it's hard to tell without further details it's anything else): TraceEvent does a lot of temporary allocations on the heap during profiling and even though those do get freed, .net runtime keeps (and grows) the memory excessively as long as there's some available. Maybe you could try configuring GC limits if that's an option.

CPU: what is your configuration (TracesSampleRate and ProfilesSampleRate)? How many transactions are happening per second?

vaind avatar Nov 19 '24 08:11 vaind

@vaind thank for your response

This is my sentry configuration

  "Sentry": {
    "Dsn": "[email protected]/4",
    "Release": "1.0.0",
    "SendDefaultPii": true,
    "MaxRequestBodySize": "Always",
    "MinimumBreadcrumbLevel": "Debug",
    "MinimumEventLevel": "Warning",
    "AttachStackTrace": true,
    "Debug": false,
    "DiagnosticLevel": "Error",
    "TracesSampleRate": 1.0,
    "ProfilesSampleRate": 0.1
  },

Transactions: 140 TPM in an hour period

aalirezamoradii avatar Nov 19 '24 10:11 aalirezamoradii

Closing this issue as it hasn't seen any activity for a while. @aalirezamoradii feel free to reopen if you're still experiencing difficulties.

jamescrosswell avatar Sep 16 '25 03:09 jamescrosswell