Starts in:
0 DAY
21 HRS
6 MIN
18 SEC
Starts in:
0 D
21 H
6 M
18 S
Open Closed

ABP and Sentry integration #5248


User avatar
0
akaziuka created
  • ABP Framework version: v7.2.2
  • UI type: Angular / Blazor (for the public site)
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): AuthServer is separated

Steps to reproduce:

  • Generate a solution based on the Application Template
  • Using official Sentry documentation here: https://docs.sentry.io/platforms/dotnet/guides/aspnetcore/ add changes to the appsettings.json file in the 'xxx.HttpApi.Host' (backend) project.
  • Add changes in the Program.cs like this:
var builder = WebApplication.CreateBuilder(args);
            builder.Host
                .AddAppSettingsSecretsJson()
                .UseAutofac()
                .UseSerilog();
            await builder.AddApplicationAsync<_3MHttpApiHostModule>();
            var app = builder.Build();
            await app.InitializeApplicationAsync();
            await app.RunAsync();
            app.UseSentryTracing();
            return 0;
  • Build solution via etc/build/build-images-locally.ps1
  • Run solution in Docker by executing etc/docker/run-docker.ps1
  • Open the app, call APIs and observe Sentry Dashboard for incoming performance logs The issue is that the integration does not work. Nothing happens after the change is implemented according to instructions. Not sure is the place is correct.

Another question: The official documentation from Sentry suggests using builder.WebHost.UseSentry(); construction. However, the ABP code does not use WebHost. Is there a workaround for that?

Please advise.


2 Answer(s)
  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try:

    var builder = WebApplication.CreateBuilder(args);
        builder.WebHost.UseSentry();
        builder.Host
            .AddAppSettingsSecretsJson()
            .UseAutofac()
            .UseSerilog();
        await builder.AddApplicationAsync<MyProjectNameWebPublicModule>();
        var app = builder.Build();
        app.UseSentryTracing();
        await app.InitializeApplicationAsync();
        await app.RunAsync();
        return 0;
    
  • User Avatar
    0
    akaziuka created

    Hi,

    You can try:

    var builder = WebApplication.CreateBuilder(args); 
        builder.WebHost.UseSentry(); 
        builder.Host 
            .AddAppSettingsSecretsJson() 
            .UseAutofac() 
            .UseSerilog(); 
        await builder.AddApplicationAsync<MyProjectNameWebPublicModule>(); 
        var app = builder.Build(); 
        app.UseSentryTracing(); 
        await app.InitializeApplicationAsync(); 
        await app.RunAsync(); 
        return 0; 
    

    This configuration worked (I saw from the logs it was initializing) but it didn't send transactions to Sentry. I got in contact with Sentry support, and theit support suggested making a change to appsettings,json to include "TracesSampleRate": "1.0" parameter. My config started looking like this: It worked like a charm. Thanks for the help.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06