Skip to content

Commit 582d088

Browse files
authored
Merge pull request #163 from F1nZeR/feature/aspnetcore-webhostbuilder-extension
Added overload for AspNetCore UseSentry method
2 parents 3ed474d + 777e451 commit 582d088

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Sentry.AspNetCore/SentryWebHostBuilderExtensions.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ public static IWebHostBuilder UseSentry(this IWebHostBuilder builder, string dsn
4141
public static IWebHostBuilder UseSentry(
4242
this IWebHostBuilder builder,
4343
Action<SentryAspNetCoreOptions> configureOptions)
44+
=> builder.UseSentry((context, options) => configureOptions?.Invoke(options));
45+
46+
/// <summary>
47+
/// Uses Sentry integration.
48+
/// </summary>
49+
/// <param name="builder">The builder.</param>
50+
/// <param name="configureOptions">The configure options.</param>
51+
/// <returns></returns>
52+
public static IWebHostBuilder UseSentry(
53+
this IWebHostBuilder builder,
54+
Action<WebHostBuilderContext, SentryAspNetCoreOptions> configureOptions)
4455
{
4556
// The earliest we can hook the SDK initialization code with the framework
4657
// Initialization happens at a later time depending if the default MEL backend is enabled or not.
@@ -54,7 +65,10 @@ public static IWebHostBuilder UseSentry(
5465

5566
if (configureOptions != null)
5667
{
57-
logging.Services.Configure(configureOptions);
68+
logging.Services.Configure<SentryAspNetCoreOptions>(options =>
69+
{
70+
configureOptions(context, options);
71+
});
5872
}
5973

6074
logging.Services.AddSingleton<IConfigureOptions<SentryAspNetCoreOptions>, SentryAspNetCoreOptionsSetup>();

0 commit comments

Comments
 (0)