Skip to content

Commit 701f569

Browse files
authored
.NET housekeeping (#7477)
1 parent 807b659 commit 701f569

File tree

21 files changed

+75
-85
lines changed

21 files changed

+75
-85
lines changed

src/platform-includes/configuration/config-intro/dotnet.mdx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Options can be set from a function provided to the `SentrySdk.Init` method. For example:
1+
For example, initialize with `SentrySdk.Init` in your `Program.cs` file:
22

33
<SignInNote />
44

@@ -15,19 +15,27 @@ SentrySdk.Init(options =>
1515
// When debug is enabled, the Sentry client will emit detailed debugging information to the console.
1616
// This might be helpful, or might interfere with the normal operation of your application.
1717
// We enable it here for demonstration purposes when first trying Sentry.
18-
// You should not do this in your applications unless you are troubleshooting issues with Sentry.
18+
// You shouldn't do this in your applications unless you're troubleshooting issues with Sentry.
1919
options.Debug = true;
2020

21-
// This option is recommended, which enables Sentry's "Release Health" feature.
21+
// This option is recommended. It enables Sentry's "Release Health" feature.
2222
options.AutoSessionTracking = true;
2323

24-
// This option is recommended for client applications only. It ensures all threads use the same global scope.
25-
// If you are writing a background service of any kind, you should remove this.
26-
options.IsGlobalModeEnabled = true;
24+
// Enabling this option is recommended for client applications only. It ensures all threads use the same global scope.
25+
options.IsGlobalModeEnabled = false;
2726

2827
// This option will enable Sentry's tracing features. You still need to start transactions and spans.
2928
options.EnableTracing = true;
29+
30+
// Example sample rate for your transactions: captures 10% of transactions
31+
options.TracesSampleRate = 0.1;
3032
});
3133
```
3234

33-
<PlatformContent includePath="getting-started-confignote" />
35+
<Note>
36+
37+
After you have configured Sentry in your code, you can also configure the
38+
[MSBuild setup](/platforms/dotnet/configuration/msbuild/) for your project. While this step is optional,
39+
it can greatly improve your Sentry experience.
40+
41+
</Note>

src/platform-includes/enriching-events/breadcrumbs/before-breadcrumb/dotnet.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
using Sentry;
33

44
// Add this to the SDK initialization callback
5-
options.BeforeBreadcrumb = breadcrumb
5+
options.SetBeforeBreadcrumb(breadcrumb
66
// Ignore breadcrumbs from Spammy logger
77
=> breadcrumb.Category == "Spammy.Logger"
88
? null
9-
: breadcrumb;
9+
: breadcrumb);
1010
```
1111

1212
```fsharp
1313
open Sentry
1414
1515
// Add this to the SDK initialization callback
16-
options.BeforeBreadcrumb <- (fun breadcrumb ->
16+
options.SetBeforeBreadcrumb(fun breadcrumb ->
1717
// Ignore breadcrumbs from Spammy logger
1818
if breadcrumb.Category = "Spammy.Logger" then
1919
null

src/platform-includes/getting-started-config/dotnet.aspnet.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ namespace AspNetMvc
2525
// Get ASP.NET integration
2626
o.AddAspNet();
2727

28-
// Collect 100% traces for testing purposes
29-
// (consider using a smaller value when running in production)
30-
o.TracesSampleRate = 1.0;
28+
// This option will enable Sentry's tracing features. You still need to start transactions and spans.
29+
o.EnableTracing = true;
30+
31+
// Example sample rate for your transactions: captures 10% of transactions
32+
o.TracesSampleRate = 0.1;
3133
});
3234
}
3335

src/platform-includes/getting-started-config/dotnet.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ SentrySdk.Init(options =>
2121
// This option is recommended. It enables Sentry's "Release Health" feature.
2222
options.AutoSessionTracking = true;
2323

24-
// This option is recommended for client applications only. It ensures all threads use the same global scope.
25-
// If you're writing a background service of any kind, you should remove this.
26-
options.IsGlobalModeEnabled = true;
24+
// Enabling this option is recommended for client applications only. It ensures all threads use the same global scope.
25+
options.IsGlobalModeEnabled = false;
2726

2827
// This option will enable Sentry's tracing features. You still need to start transactions and spans.
2928
options.EnableTracing = true;
29+
30+
// Example sample rate for your transactions: captures 10% of transactions
31+
options.TracesSampleRate = 0.1;
3032
});
3133
```
3234

33-
<PlatformContent includePath="getting-started-confignote" />
35+
<Note>
36+
37+
After you have configured Sentry in your code, you can also configure the
38+
[MSBuild setup](/platforms/dotnet/configuration/msbuild/) for your project. While this step is optional,
39+
it can greatly improve your Sentry experience.
40+
41+
</Note>

src/platform-includes/getting-started-confignote/dotnet.mdx

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/platform-includes/set-fingerprint/basic/dotnet.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
```csharp
22
// Add this to the SDK initialization callback
3-
options.BeforeSend = @event =>
3+
options.SetBeforeSend(@event =>
44
{
55
if (@event.Exception is SqlConnectionException ex)
66
{
77
@event.SetFingerprint(new [] { "database-connection-error" });
88
}
99

1010
return @event;
11-
};
11+
});
1212
```
1313

1414
```fsharp
1515
// Add this to the SDK initialization callback
16-
options.BeforeSend <- (fun event ->
16+
options.SetBeforeSend(fun event ->
1717
match event.Exception with
1818
| :? SqlConnectionException -> event.SetFingerprint(["database-connection-error"])
1919
| _ -> ()

src/platform-includes/set-fingerprint/database-connection/dotnet.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
```csharp
22
// Add this to the SDK initialization callback
3-
options.BeforeSend = @event =>
3+
options.SetBeforeSend(@event =>
44
{
55
if (@event.Exception is SqlConnectionException ex)
66
{
77
@event.SetFingerprint(new [] { "database-connection-error" });
88
}
99

1010
return @event;
11-
};
11+
});
1212
```
1313

1414
```fsharp
15-
options.BeforeSend <- (fun event ->
15+
options.SetBeforeSend(fun event ->
1616
match event.Exception with
1717
| :? SqlConnectionException -> event.SetFingerprint(["database-connection-error"])
1818
| _ -> ()

src/platform-includes/set-fingerprint/rpc/dotnet.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class MyRpcException : Exception
99
}
1010

1111
// Add this to the SDK initialization callback
12-
options.BeforeSend = @event =>
12+
options.SetBeforeSend(@event =>
1313
{
1414
if (@event.Exception is MyRpcException ex)
1515
{
@@ -24,7 +24,7 @@ options.BeforeSend = @event =>
2424
}
2525

2626
return @event;
27-
};
27+
});
2828
```
2929

3030
```fsharp
@@ -36,7 +36,7 @@ type MyRpcException() =
3636
member val Code: HttpStatusCode = HttpStatusCode.OK with get, set
3737
3838
// Add this to the SDK initialization callback
39-
options.BeforeSend <- (fun event ->
39+
options.SetBeforeSend(fun event ->
4040
match event.Exception with
4141
| :? MyRpcException as ex -> event.SetFingerprint([
4242
"{{ default }}"

src/platform-includes/set-fingerprint/rpc/dotnet.xamarin.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class MyRpcException : Exception
99
}
1010

1111
// Add this to the SDK initialization callback
12-
options.BeforeSend = @event =>
12+
options.SetBeforeSend(@event =>
1313
{
1414
if (@event.Exception is MyRpcException ex)
1515
{
@@ -24,5 +24,5 @@ options.BeforeSend = @event =>
2424
}
2525

2626
return @event;
27-
};
27+
});
2828
```

src/platform-includes/set-fingerprint/static/dotnet.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
```csharp
22
// Add this to the SDK initialization callback
3-
options.BeforeSend = @event =>
3+
options.SetBeforeSend(@event =>
44
{
55
@event.SetFingerprint(
66
new []
@@ -10,12 +10,12 @@ options.BeforeSend = @event =>
1010
);
1111

1212
return @event;
13-
};
13+
});
1414
```
1515

1616
```fsharp
1717
// Add this to the SDK initialization callback
18-
options.BeforeSend <- (fun event ->
18+
options.SetBeforeSend(fun event ->
1919
event.SetFingerprint(["my-view-function"])
2020
event
2121
)

0 commit comments

Comments
 (0)