You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use Elastic.Apm in bridge mode the exceptions are recorded on Activity.RecordExceptions, I don't see them on "Errors" tab
To Reproduce
usingSystem.Diagnostics;usingElastic.Apm.AspNetCore;usingOpenTelemetry.Metrics;usingOpenTelemetry.Trace;varbuilder=WebApplication.CreateBuilder(args);builder.Logging.AddOpenTelemetry(logging =>{logging.IncludeFormattedMessage=true;logging.IncludeScopes=true;});builder.Services.AddOpenTelemetry().WithTracing(tracing =>{if(builder.Environment.IsDevelopment()){// We want to view all traces in developmenttracing.SetSampler(newAlwaysOnSampler());}tracing.AddSource("Worker").AddHttpClientInstrumentation().AddAspNetCoreInstrumentation().AddConsoleExporter();});builder.Services.AddHostedService<Worker>();varapp=builder.Build();app.UseElasticApm(app.Configuration);app.MapGet("/",()=>"Hello World!");app.Run();publicclassWorker:BackgroundService{publicstaticreadonlyActivitySourceActivitySource=new("Worker");protectedoverrideasyncTaskExecuteAsync(CancellationTokenstoppingToken){while(!stoppingToken.IsCancellationRequested){usingvaractivity=ActivitySource.StartActivity("Worker.ExecuteAsync");try{thrownewException("Something went wrong");}catch(Exceptionex){activity?.SetStatus(Status.Error.WithDescription(ex.Message));activity?.RecordException(ex);}awaitTask.Delay(TimeSpan.FromSeconds(15),stoppingToken);}}}
RecordException is an extension method of the OTel SDK. The bridge is designed to capture spans directly from the .NET Activity APIs. If you're using the OTel SDK, you can send OTLP directly to Elastic APM rather than rely on our SDK and the bridge. Is anything blocking you from using the OTLP exporter from the SDK, rather than our APM Agent? We also have a distro you might want to check out. Therefore, the current behaviour is expected.
In .NET 9 (and System.Diagnostics.DiagnosticSource 9), a dedicated AddException method is being added. Once that is released, we will review if that's something we can and should bridge as an APM error.
@NikiforovAll, I'll review the docs when we update for .NET 9, but I'm not sure this needs to be a note there as we don't imply we support anything except for the .NET API.
APM Agent version
Elastic Cloud / APM
Environment
windows, net8
Describe the bug
When I use
Elastic.Apm
in bridge mode the exceptions are recorded onActivity.RecordExceptions
, I don't see them on "Errors" tabTo Reproduce
Steps to reproduce the behavior:
Run the code above.
Expected behavior
I can find errors on the "Errors" tab.
Actual behavior
No errors are registered
The text was updated successfully, but these errors were encountered: