Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/actions/environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 22 additions & 2 deletions samples/Sentry.Samples.AspNetCore.Basic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ILoggerFactory>()
.CreateLogger<Program>();

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();
Loading