Repository navigation
fix(onboarding): Update ASP.NET Core snippets to minimal hosting - #127238
Merged
Merged
Conversation
The ASP.NET Core onboarding still showed the pre-.NET 6 CreateHostBuilder template, a tracing step pointing at Startup.cs with no code, and an MVC span sample that didn't compile (CS0161). The shared .NET metrics verify snippet started with `using Sentry;`, which fails with CS1529 when pasted into Program.cs after builder.Build(). Show the WebApplication form with UseSentry and Build() as separate statements, place the verify call between Build() and Run(), use an app.MapGet endpoint taking IHub for the span example, drop the stale F# sample links, and bump the fallback version to 6.12.1. Refs getsentry/sentry-dotnet#5700 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ternals The tracing step explained that UseSentry adds a middleware, and the configure step explained the IWebHostBuilder return type. Neither tells a new user anything they need. Say what they get instead: every request is traced once TracesSampleRate is set, and chaining .Build() onto UseSentry makes app.MapGet fail to compile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ric-oliv
marked this pull request as ready for review
October 13, 2026 12:16
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ASP.NET Core onboarding still shows the pre-.NET 6 template, so its snippets don't fit a project created with
dotnet new web, and two of them don't compile:CreateHostBuilderwithHost.CreateDefaultBuilder(args).ConfigureWebHostDefaults(...). A minimal-hostingProgram.cshas no class to put it in..Build()ontobuilder.WebHost.UseSentry(...)builds anIWebHostinstead of theWebApplication. That fails with CS1929 and, on .NET 10, also raises the ASPDEPR008 warning.Startup.cs, then shows no code.using Sentry;. Pasted intoProgram.csafterbuilder.Build(), it fails:Changes
WebApplication.CreateBuilder(args),builder.WebHost.UseSentry(...), thenvar app = builder.Build();as its own statement, with one sentence saying why.CaptureMessagecall is shown betweenbuilder.Build()andapp.Run(). The DI sentence now explainsIHubin the text, and the unit-testing link sits on "easier to test".TracesSampleRateis set. The span example is anapp.MapGetendpoint that takesIHubas a parameter, replacing the MVC controller.using Sentry;. The logs verify snippet never had it, and the Sentry package adds theSentrynamespace as an implicit using wheneverImplicitUsingsis on, which every .NET 6+ template enables.sentry-demos/fsharp, last updated in 2023, andsentry-demos/giraffe, in 2021).4.3.0→6.12.1.MapGetexample render, and thatCreateHostBuilderdoesn't.Testing
I took every snippet on the page, as rendered from these files with all products selected, and pasted it into a fresh
dotnet new webproject with Sentry.AspNetCore 6.12.1. It builds with no warnings on .NET 8, 10 and 11. Run against a local envelope receiver, the message, both logs, the counter, distribution and gauge, and theGET /person/{id}transaction with itsadditional-workspan all arrive.Refs getsentry/sentry-dotnet#5700