diff --git a/.github/actions/environment/action.yml b/.github/actions/environment/action.yml index bdf5139596..40badbd3a7 100644 --- a/.github/actions/environment/action.yml +++ b/.github/actions/environment/action.yml @@ -73,9 +73,6 @@ runs: shell: bash run: | pwd - dotnet workload install \ - wasm-tools wasm-tools-net8 maui-android android mobile-librarybuilder \ - ${{ runner.os == 'macOS' && 'maui-ios maui-maccatalyst maui-windows macos' || '' }} \ - ${{ runner.os == 'Windows' && 'maui-ios maui-maccatalyst maui-windows' || '' }} \ + dotnet workload restore \ --temp-dir "${{ runner.temp }}" \ --skip-sign-check diff --git a/samples/Sentry.Samples.AspNetCore.Basic/Program.cs b/samples/Sentry.Samples.AspNetCore.Basic/Program.cs index e4767ad918..cb8a4da994 100644 --- a/samples/Sentry.Samples.AspNetCore.Basic/Program.cs +++ b/samples/Sentry.Samples.AspNetCore.Basic/Program.cs @@ -19,8 +19,7 @@ var app = builder.Build(); -// An example ASP.NET Core middleware that throws an -// exception when serving a request to path: /throw +// An example ASP.NET Core endpoint that throws an exception when serving a request to path: /throw app.MapGet("/throw/{message?}", context => { var exceptionMessage = context.GetRouteValue("message") as string; @@ -48,4 +47,25 @@ exceptionMessage ?? "An exception thrown from the ASP.NET Core pipeline"); }); +// Demonstrates how to add tracing in custom middleware +app.Use(async (context, next) => +{ + var span = SentrySdk.StartSpan("CustomMiddlewareSpan", "middleware"); + try + { + var log = context.RequestServices.GetRequiredService() + .CreateLogger(); + + log.LogInformation("Just chilling for a bit..."); + await Task.Delay(TimeSpan.FromMilliseconds(50)); // Simulate some work + span.Finish(); + } + catch (Exception e) + { + span.Finish(e); + throw; + } + await next(); +}); + app.Run();