Skip to content

Commit dd39a67

Browse files
a-haritibitsandfoxes
authored andcommitted
refactor: migrate DotNet sdks to inline product options syntax (#13415)
1 parent 8673e33 commit dd39a67

File tree

13 files changed

+57
-17
lines changed

13 files changed

+57
-17
lines changed

docs/platforms/dotnet/guides/aspnet/index.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ as well as your logs as breadcrumbs. The logging integrations also capture event
3434
You configure the SDK in the `Global.asax.cs`:
3535

3636

37-
```csharp {"onboardingOptions": {"performance": "22-25, 35-44"}}
37+
```csharp
3838
using System;
3939
using System.Web;
4040
using Sentry.AspNet;
@@ -56,9 +56,11 @@ public class MvcApplication : HttpApplication
5656
// Adds request URL and headers, IP and name for users, etc.
5757
options.SendDefaultPii = true;
5858

59+
// ___PRODUCT_OPTION_START___ performance
5960
// Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring.
6061
// We recommend adjusting this value in production.
6162
options.TracesSampleRate = 1.0;
63+
// ___PRODUCT_OPTION_END___ performance
6264
6365
// If you also installed the Sentry.EntityFramework package
6466
options.AddEntityFramework();
@@ -69,6 +71,7 @@ public class MvcApplication : HttpApplication
6971
// Global error catcher
7072
protected void Application_Error() => Server.CaptureLastError();
7173

74+
// ___PRODUCT_OPTION_START___ performance
7275
protected void Application_BeginRequest()
7376
{
7477
Context.StartSentryTransaction();
@@ -78,6 +81,7 @@ public class MvcApplication : HttpApplication
7881
{
7982
Context.FinishSentryTransaction();
8083
}
84+
// ___PRODUCT_OPTION_END___ performance
8185
8286
protected void Application_End()
8387
{

docs/platforms/dotnet/guides/aspnetcore/index.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The framework takes configuration settings from `appsettings.json`, environment
6969
An example of some of the options that can be configured via `appsettings.json`:
7070

7171

72-
```json {filename:appsettings.json} {"onboardingOptions": {"performance": "10"}}
72+
```json {filename:appsettings.json}
7373
"Sentry": {
7474
"Dsn": "___PUBLIC_DSN___",
7575
"SendDefaultPii": true,
@@ -79,7 +79,9 @@ An example of some of the options that can be configured via `appsettings.json`:
7979
"AttachStackTrace": true,
8080
"Debug": true,
8181
"DiagnosticLevel": "Error",
82+
// ___PRODUCT_OPTION_START___ performance
8283
"TracesSampleRate": 1.0
84+
// ___PRODUCT_OPTION_END___ performance
8385
},
8486
```
8587

@@ -107,11 +109,13 @@ ASP.NET Core will automatically read this environment variable and bind it to th
107109

108110
Finally, any settings that can be configured via `appsettings.json` or environment variables can also be configured via code. Some settings can only be configured in code, such as the `BeforeSend` callback:
109111

110-
```csharp {"onboardingOptions": {"performance": "4"}}
112+
```csharp
111113
.UseSentry(options =>
112114
{
113115
options.SendDefaultPii = true; // Adds request URL and headers, IP and name for users, etc.
116+
// ___PRODUCT_OPTION_START___ performance
114117
options.TracesSampleRate = 1.0; // Set this to configure automatic tracing
118+
// ___PRODUCT_OPTION_END___ performance
115119
options.SetBeforeSend((@event, hint) =>
116120
{
117121
// Never report server names
@@ -121,10 +125,12 @@ Finally, any settings that can be configured via `appsettings.json` or environme
121125
})
122126
```
123127

124-
```fsharp {"onboardingOptions": {"performance": "3"}}
128+
```fsharp
125129
.UseSentry (fun options ->
126130
options.SendDefaultPii <- true // Adds request URL and headers, IP and name for users, etc.
131+
// ___PRODUCT_OPTION_START___ performance
127132
options.TracesSampleRate <- 1.0 // Set this to configure automatic tracing
133+
// ___PRODUCT_OPTION_END___ performance
128134
options.SetBeforeSend(fun event hint ->
129135
// Never report server names
130136
event.ServerName <- null

docs/platforms/dotnet/guides/aws-lambda/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ All `ASP.NET Core` configurations are valid here. But one configuration in parti
3535
`FlushOnCompletedRequest` ensures all events are flushed out. This is because the general ASP.NET Core hooks for when the process is exiting are not guaranteed to run in a serverless environment. This setting ensures that no event is lost if AWS recycles the process.
3636

3737

38-
```csharp {"onboardingOptions": {"performance": "14-17"}}
38+
```csharp
3939
public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
4040
{
4141
protected override void Init(IWebHostBuilder builder)
@@ -49,10 +49,12 @@ public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFu
4949
o.Debug = true;
5050
// Adds request URL and headers, IP and name for users, etc.
5151
o.SendDefaultPii = true;
52+
// ___PRODUCT_OPTION_START___ performance
5253
// Set TracesSampleRate to 1.0 to capture 100%
5354
// of transactions for tracing.
5455
// We recommend adjusting this value in production
5556
o.TracesSampleRate = 1.0;
57+
// ___PRODUCT_OPTION_END___ performance
5658
// Required in Serverless environments
5759
options.FlushOnCompletedRequest = true;
5860
})

docs/platforms/dotnet/guides/azure-functions-worker/index.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extens
3333

3434
Sentry integration with Azure Functions is done by calling `.UseSentry()` and specifying the options, for example:
3535

36-
```csharp {"onboardingOptions": {"performance": "12-14"}}
36+
```csharp
3737
using Sentry.Azure.Functions.Worker;
3838

3939
var builder = FunctionsApplication.CreateBuilder(args);
@@ -45,9 +45,11 @@ builder.UseSentry(options =>
4545
options.Debug = true;
4646
// Adds request URL and headers, IP and name for users, etc.
4747
options.SendDefaultPii = true;
48+
// ___PRODUCT_OPTION_START___ performance
4849
// Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring.
4950
// We recommend adjusting this value in production.
5051
options.TracesSampleRate = 1.0;
52+
// ___PRODUCT_OPTION_END___ performance
5153
});
5254

5355
builder.Build().Run();
@@ -59,7 +61,7 @@ If using the ASP.NET Core integration add `UseSentry` to the `ConfigureFunctions
5961

6062
</Alert>
6163

62-
```csharp {"onboardingOptions": {"performance": "13-15"}}
64+
```csharp
6365
using Sentry.Azure.Functions.Worker;
6466

6567
var host = new HostBuilder()
@@ -72,9 +74,11 @@ var host = new HostBuilder()
7274
options.Debug = true;
7375
// Adds request URL and headers, IP and name for users, etc.
7476
options.SendDefaultPii = true;
77+
// ___PRODUCT_OPTION_START___ performance
7578
// Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring.
7679
// We recommend adjusting this value in production.
7780
options.TracesSampleRate = 1.0;
81+
// ___PRODUCT_OPTION_END___ performance
7882
});
7983
})
8084
.Build();

docs/platforms/dotnet/guides/blazor-webassembly/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Sentry integration with Blazor WebAssembly is done by calling `.UseSentry()` and
2828

2929

3030

31-
```csharp {"onboardingOptions": {"performance": "9"}}
31+
```csharp
3232
var builder = WebAssemblyHostBuilder.CreateDefault(args);
3333
builder.UseSentry(options =>
3434
{
@@ -37,7 +37,9 @@ builder.UseSentry(options =>
3737
options.Debug = true;
3838
// Adds request URL and headers, IP and name for users, etc.
3939
options.SendDefaultPii = true;
40+
// ___PRODUCT_OPTION_START___ performance
4041
options.TracesSampleRate = 0.1;
42+
// ___PRODUCT_OPTION_END___ performance
4143
});
4244

4345
// Captures logError and higher as events

docs/platforms/dotnet/guides/entityframework/index.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Add the Entity Framework 6 support to your project in one step:
4545

4646
For example, configuring an ASP.NET app with _global.asax_:
4747

48-
```csharp {filename:global.asax} {"onboardingOptions": {"performance": "17-19, 28-37"}}
48+
```csharp {filename:global.asax}
4949
using System;
5050
using System.Configuration;
5151
using Sentry.AspNet;
@@ -62,9 +62,11 @@ public class MvcApplication : System.Web.HttpApplication
6262
options.Dsn = ConfigurationManager.AppSettings["SentryDsn"];
6363
// Adds request URL and headers, IP and name for users, etc.
6464
options.SendDefaultPii = true;
65+
// ___PRODUCT_OPTION_START___ performance
6566
// Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring.
6667
// We recommend adjusting this value in production.
6768
options.TracesSampleRate = 1.0;
69+
// ___PRODUCT_OPTION_END___ performance
6870
// Add the EntityFramework integration
6971
options.AddEntityFramework();
7072
});
@@ -73,6 +75,7 @@ public class MvcApplication : System.Web.HttpApplication
7375
// Global error catcher
7476
protected void Application_Error() => Server.CaptureLastError();
7577

78+
// ___PRODUCT_OPTION_START___ performance
7679
protected void Application_BeginRequest()
7780
{
7881
Context.StartSentryTransaction();
@@ -83,6 +86,7 @@ public class MvcApplication : System.Web.HttpApplication
8386
Context.FinishSentryTransaction();
8487
}
8588

89+
// ___PRODUCT_OPTION_END___ performance
8690
public override void Dispose()
8791
{
8892
_sentrySdk.Dispose();

docs/platforms/dotnet/guides/maui/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extens
4545
In your `MauiProgram.cs` file, call `UseSentry` on your `MauiAppBuilder`, and include any options you would like to set. The `Dsn` is the only required parameter.
4646

4747

48-
```csharp {"onboardingOptions": {"performance": "22-25"}}
48+
```csharp
4949
public static MauiApp CreateMauiApp()
5050
{
5151
var builder = MauiApp.CreateBuilder();
@@ -67,9 +67,11 @@ public static MauiApp CreateMauiApp()
6767
// Adds request URL and headers, IP and name for users, etc.
6868
options.SendDefaultPii = true;
6969

70+
// ___PRODUCT_OPTION_START___ performance
7071
// Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
7172
// We recommend adjusting this value in production.
7273
options.TracesSampleRate = 1.0;
74+
// ___PRODUCT_OPTION_END___ performance
7375
7476
// Other Sentry options can be set here.
7577
})

docs/platforms/dotnet/guides/uwp/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The SDK should be initialized in the constructor of your application class (usua
2828
</Alert>
2929

3030

31-
```csharp {"onboardingOptions": {"performance": "20-23"}}
31+
```csharp
3232
using Sentry.Protocol;
3333
using UnhandledExceptionEventArgs = Windows.UI.Xaml.UnhandledExceptionEventArgs;
3434

@@ -48,10 +48,12 @@ sealed partial class App : Application
4848
// Adds request URL and headers, IP and name for users, etc.
4949
options.SendDefaultPii = true;
5050

51+
// ___PRODUCT_OPTION_START___ performance
5152
// Set traces_sample_rate to 1.0 to capture 100% of transactions for tracing.
5253
// We recommend adjusting this value in production.
5354
options.TracesSampleRate = 1.0;
5455

56+
// ___PRODUCT_OPTION_END___ performance
5557
// Enable Global Mode since this is a client app.
5658
options.IsGlobalModeEnabled = true;
5759

docs/platforms/dotnet/guides/winforms/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ You should also set `Application.SetUnhandledExceptionMode(UnhandledExceptionMod
3030
A complete example of the recommended startup is as follows:
3131

3232

33-
```csharp {"onboardingOptions": {"performance": "34-37"}}
33+
```csharp
3434
using System;
3535
using System.Windows.Forms;
3636

@@ -64,10 +64,12 @@ namespace WindowsFormsApp1
6464
// Adds request URL and headers, IP and name for users, etc.
6565
options.SendDefaultPii = true;
6666

67+
// ___PRODUCT_OPTION_START___ performance
6768
// Set traces_sample_rate to 1.0 to capture 100% of transactions for tracing.
6869
// We recommend adjusting this value in production.
6970
TracesSampleRate = 1.0,
7071

72+
// ___PRODUCT_OPTION_END___ performance
7173
// Enable Global Mode since this is a client app
7274
IsGlobalModeEnabled = true,
7375

docs/platforms/dotnet/guides/winui/index.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ In addition to capturing errors, you can monitor interactions between multiple s
3232

3333
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
3434

35-
```csharp {"onboardingOptions": {"performance": "19-22"}}
35+
```csharp
3636
using Sentry.Protocol;
3737

3838
sealed partial class App : Application
@@ -50,10 +50,12 @@ sealed partial class App : Application
5050

5151
// Adds request URL and headers, IP and name for users, etc.
5252
options.SendDefaultPii = true;
53+
// ___PRODUCT_OPTION_START___ performance
5354
5455
// Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
5556
// We recommend adjusting this value in production.
5657
options.TracesSampleRate = 1.0;
58+
// ___PRODUCT_OPTION_END___ performance
5759
5860
// Enable Global Mode since this is a client app.
5961
options.IsGlobalModeEnabled = true;
@@ -80,7 +82,7 @@ Do not initialize the SDK in the `OnLaunched` event of the application or the `H
8082
</Alert>
8183

8284

83-
```csharp {"onboardingOptions": {"performance": "21-24"}}
85+
```csharp
8486
// Add these to your existing using statements.
8587
using Sentry.Protocol;
8688
using UnhandledExceptionEventArgs = Microsoft.UI.Xaml.UnhandledExceptionEventArgs;
@@ -100,10 +102,12 @@ sealed partial class App : Application
100102

101103
// Adds request URL and headers, IP and name for users, etc.
102104
o.SendDefaultPii = true;
105+
// ___PRODUCT_OPTION_START___ performance
103106
104107
// Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing.
105108
// We recommend adjusting this value in production.
106109
o.TracesSampleRate = 1.0;
110+
// ___PRODUCT_OPTION_END___ performance
107111
108112
// Enable Global Mode since this is a client app.
109113
o.IsGlobalModeEnabled = true;

0 commit comments

Comments
 (0)