From 619ce0b4ada195d83d0cae4a8cd21de74ad82b4b Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:11:37 +0000 Subject: [PATCH 1/6] feat(docs): Apply new quick start template to .NET quick start guides Co-Authored-By: Shannon Anahata --- docs/platforms/dotnet/guides/aspnet/index.mdx | 74 +++++-- .../dotnet/guides/aspnetcore/index.mdx | 188 ++++++++++++------ .../dotnet/guides/aws-lambda/index.mdx | 60 ++++-- .../guides/azure-functions-worker/index.mdx | 93 ++++++--- .../dotnet/guides/blazor-server/index.mdx | 70 ++++++- .../guides/blazor-webassembly/index.mdx | 74 ++++++- .../dotnet/guides/entityframework/index.mdx | 74 +++++-- docs/platforms/dotnet/guides/maui/index.mdx | 86 ++++++-- .../dotnet/guides/winforms/index.mdx | 70 +++++-- docs/platforms/dotnet/guides/winui/index.mdx | 76 +++++-- docs/platforms/dotnet/guides/wpf/index.mdx | 68 +++++-- .../platforms/dotnet/guides/xamarin/index.mdx | 61 ++++-- docs/platforms/dotnet/index.mdx | 98 +++++---- .../getting-started-verify/dotnet.mdx | 14 +- .../getting-started-verify/dotnet.xamarin.mdx | 4 +- 15 files changed, 809 insertions(+), 301 deletions(-) diff --git a/docs/platforms/dotnet/guides/aspnet/index.mdx b/docs/platforms/dotnet/guides/aspnet/index.mdx index 0f9f035ef343f..9137143b1cf56 100644 --- a/docs/platforms/dotnet/guides/aspnet/index.mdx +++ b/docs/platforms/dotnet/guides/aspnet/index.mdx @@ -6,16 +6,7 @@ description: "Learn about Sentry's .NET integration with ASP.NET." Sentry provides an integration with ASP.NET through the [Sentry.AspNet NuGet package](https://www.nuget.org/packages/Sentry.AspNet). -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - - Add the Sentry dependency: ```powershell {tabTitle:Package Manager} @@ -31,9 +22,21 @@ as well as your logs as breadcrumbs. The logging integrations also capture event ## Configure +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + + You configure the SDK in the `Global.asax.cs`: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` +- Logs from logging integrations: via `EnableLogs` + +Don't need a feature? Remove its options from the snippet. + ```csharp using System; using System.Web; @@ -55,12 +58,12 @@ public class MvcApplication : HttpApplication options.Debug = true; // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - - // ___PRODUCT_OPTION_START___ performance - // Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. + options.EnableLogs = true; + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 1.0; - // ___PRODUCT_OPTION_END___ performance // If you also installed the Sentry.EntityFramework package options.AddEntityFramework(); @@ -70,8 +73,6 @@ public class MvcApplication : HttpApplication // Global error catcher protected void Application_Error() => Server.CaptureLastError(); - - // ___PRODUCT_OPTION_START___ performance protected void Application_BeginRequest() { Context.StartSentryTransaction(); @@ -81,7 +82,6 @@ public class MvcApplication : HttpApplication { Context.FinishSentryTransaction(); } - // ___PRODUCT_OPTION_END___ performance protected void Application_End() { @@ -116,12 +116,44 @@ Opt-in to send the request body to Sentry: options.AddAspNet(RequestSize.Always); ``` -## Verify +## Send Logs + +Use `SentrySdk.Logger` to send logs at different levels without an additional option. If you also send logs through an integration, set `EnableLogs = true` in the initialization snippet. + +If you use Serilog, NLog, or log4net, see the documented Serilog, NLog, and log4net integrations. -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Troubleshooting For information about Troubleshooting, please visit the [troubleshooting](troubleshooting/) page. @@ -132,4 +164,8 @@ For information about Troubleshooting, please visit the [troubleshooting](troubl ## Next Steps +At this point, you should have integrated Sentry into your ASP.NET application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/aspnetcore/index.mdx b/docs/platforms/dotnet/guides/aspnetcore/index.mdx index 16fe5517e5588..30435f6359c60 100644 --- a/docs/platforms/dotnet/guides/aspnetcore/index.mdx +++ b/docs/platforms/dotnet/guides/aspnetcore/index.mdx @@ -6,16 +6,7 @@ description: "Learn about Sentry's .NET integration with ASP.NET Core." Sentry provides an integration with ASP.NET Core through the [Sentry.AspNetCore](https://www.nuget.org/packages/Sentry.AspNetCore) NuGet package. -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - - Add the Sentry dependency: ```powershell {tabTitle:Package Manager} @@ -32,15 +23,34 @@ paket add Sentry --version {{@inject packages.version('sentry.dotnet.aspnetcore' This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/). This means that besides the ASP.NET Core related features, through this package you'll also get access to all the framework's logging integration and also the features available in the main [Sentry](/platforms/dotnet/) SDK. -## Initialize +## Configure + +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `Microsoft.Extensions.Logging` need `EnableLogs = true`, and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. The simplest way to initialize Sentry in ASP.NET Core is by using the `UseSentry` extension method from the `Sentry.AspNetCore` package in conjunction with the [framework configuration system](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-7.0). When configuring the SDK via the frameworks configuration system, it's possible to add the SDK by simply calling `UseSentry` without providing any further information. The SDK provides this as extension methods to support ASP.NET Core `2.X`, `3.X`, and `5.X` and later: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` +- Logs: via `EnableLogs` + +Don't need a feature? Remove its options from the snippet. + ```csharp {tabTitle:WebApplication} {mdExpandTabs} var builder = WebApplication.CreateBuilder(args); -builder.WebHost.UseSentry(); // Initialize Sentry +builder.WebHost.UseSentry(options => +{ + options.EnableLogs = true; + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + options.TracesSampleRate = 1.0; +}); ``` ```csharp {tabTitle:IHostBuilder} @@ -48,19 +58,33 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { - // Add the following line: - webBuilder.UseSentry(); + webBuilder.UseSentry(options => + { + options.EnableLogs = true; + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + options.TracesSampleRate = 1.0; + }); }); ``` ```csharp {tabTitle:IWebHost} public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) - // Add the following line: - .UseSentry() + .UseSentry(options => + { + options.EnableLogs = true; + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + options.TracesSampleRate = 1.0; + }) ``` -## Configure +### Additional configuration The framework takes configuration settings from `appsettings.json`, environment variables, or from code. These settings get applied to `Sentry.AspNetCore.SentryAspNetCoreOptions`, which extends `Sentry.Extensions.Logging.SentryLoggingOptions`, which in turn extends `Sentry.SentryOptions`. This means options for `Sentry.AspNetCore` as well as all the inner packages are available to be configured through the configuration system. @@ -70,6 +94,7 @@ An example of some of the options that can be configured via `appsettings.json`: ```json {filename:appsettings.json} +{ "Sentry": { "Dsn": "___PUBLIC_DSN___", "SendDefaultPii": true, @@ -79,17 +104,12 @@ An example of some of the options that can be configured via `appsettings.json`: "AttachStackTrace": true, "Debug": true, "DiagnosticLevel": "Error", - // ___PRODUCT_OPTION_START___ performance - "TracesSampleRate": 1.0 - // ___PRODUCT_OPTION_END___ performance - }, + "TracesSampleRate": 1.0, + "EnableLogs": true + } +} ``` - - - -Setting `TracesSampleRate` to `1.0` in this example configures Sentry to capture 100% of transactions for tracing. We recommend adjusting this value in production. See Automatic Instrumentation for further information. - - +Setting `TracesSampleRate` to `1.0` captures 100% of spans. We recommend reducing this value in production. See Automatic Instrumentation for further information. ### Environment variables @@ -112,10 +132,13 @@ Finally, any settings that can be configured via `appsettings.json` or environme ```csharp .UseSentry(options => { + options.EnableLogs = true; options.SendDefaultPii = true; // Adds request URL and headers, IP and name for users, etc. - // ___PRODUCT_OPTION_START___ performance - options.TracesSampleRate = 1.0; // Set this to configure automatic tracing - // ___PRODUCT_OPTION_END___ performance + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + options.TracesSampleRate = 1.0; options.SetBeforeSend((@event, hint) => { // Never report server names @@ -127,10 +150,13 @@ Finally, any settings that can be configured via `appsettings.json` or environme ```fsharp .UseSentry (fun options -> + options.EnableLogs <- true options.SendDefaultPii <- true // Adds request URL and headers, IP and name for users, etc. - // ___PRODUCT_OPTION_START___ performance - options.TracesSampleRate <- 1.0 // Set this to configure automatic tracing - // ___PRODUCT_OPTION_END___ performance + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + options.TracesSampleRate <- 1.0 options.SetBeforeSend(fun event hint -> // Never report server names event.ServerName <- null @@ -141,21 +167,15 @@ Finally, any settings that can be configured via `appsettings.json` or environme > Example modifying all events before they are sent to avoid server names being reported. -## Verify - -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. - - - -## Dependency Injection +### Dependency Injection Much of the behavior of the ASP.NET Core integration with Sentry can be customized by using the frameworks dependency injection system. That is done by registering your own implementation of some of the exposed abstraction. -### Lifetimes +#### Lifetimes The lifetime used will be respected by the SDK. For example, when registering a `Transient` dependency, a new instance of the processor is created for each event sent out to Sentry. This allows the use of non thread-safe event processors. -### Capturing the affected user +#### Capturing the affected user When opting-in to [SendDefaultPii](#senddefaultpii), the SDK will automatically read the user from the request by inspecting `HttpContext.User`. Default claim values like `NameIdentifier` for the _Id_ will be used. @@ -173,7 +193,7 @@ member this.ConfigureServices(services: IServiceCollection) = services.AddSingleton() |> ignore ``` -### Adding event and exception processors +#### Adding event and exception processors Event processors and exception processors can be added via DI: @@ -191,17 +211,17 @@ member this.ConfigureServices(services: IServiceCollection) = services.AddScoped() |> ignore ``` -## Options and Initialization +### Options and Initialization As previously mentioned, this package is a wrapper around [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) and [Sentry](/platforms/dotnet/). Please refer to the documentation of these packages to get the options that are defined at those levels. Below, the options that are specific to `Sentry.AspNetCore` will be described. -### SendDefaultPii +#### SendDefaultPii Although this setting is part of the [Sentry](/platforms/dotnet/) package, in the context of ASP.NET Core, it means reporting the user by reading the frameworks `HttpContext.User`. The strategy to create the `SentryUser` can be customized. Please read [retrieving user info](#capturing-the-affected-user) for more. -### Environment +#### Environment The environment name is automatically populated by reading the frameworks `IHostingEnvironment` value. @@ -213,7 +233,7 @@ Methods that take precedence over `IHostingEnvironment` are: - Environment variable _SENTRY_ENVIRONMENT_ - Configuration system like `appsettings.json` -### MaxRequestBodySize +#### MaxRequestBodySize This parameter controls whether integrations should capture HTTP request bodies. It can be set to one of the following values: @@ -224,7 +244,7 @@ This parameter controls whether integrations should capture HTTP request bodies. If the request bodies should be captured, all requests will have the `EnableRewind` method invoked. This is done so that the request data can be read later, in case an error happens while processing the request. -### CaptureBlockingCalls +#### CaptureBlockingCalls When set to `true`, the SDK will detect blocking calls in async methods (like `Task.Wait()` and `Task.Result`) and report these to Sentry as errors. Blocking calls can lead to [Threadpool starvation](https://learn.microsoft.com/en-nz/archive/blogs/vancem/diagnosing-net-core-threadpool-starvation-with-perfview-why-my-service-is-not-saturating-all-cores-or-seems-to-stall). @@ -240,24 +260,18 @@ This feature makes use of the `Ben.BlockingDetector` library and so has [the sam > > It will detect CLR-initiated waits lock, `ManualResetEventSlim`, `Semaphore\{Slim\}`, `Task.Wait`, `Task.Result` etc. if they do block. -### IncludeActivityData +#### IncludeActivityData Opt-in to capture values from [System.Diagnostic.Activity](https://github.com/dotnet/runtime/blob/master/src/libraries/System.Diagnostics.DiagnosticSource/src/ActivityUserGuide.md) if one exists. -## Samples - -- A [simple example](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Basic) without MVC. (**C#**) -- An [example](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Mvc) using MVC and most of the SDK features. (**C#**) -- An [example](https://github.com/sentry-demos/giraffe) using Giraffe on top of ASP.NET Core with a basic overview of available features. (**F#**) -- For [more samples](https://github.com/getsentry/sentry-dotnet-samples) of the .NET SDKs. -## Tunnel +### Tunnel If events are being logged to Sentry from the client-side, then you should use a [tunnel](/platforms/javascript/troubleshooting/#using-the-tunnel-option). A tunnel is an HTTP endpoint that acts as a proxy between Sentry and your application. Because you control this server, there is no risk of any requests sent to it being blocked. -### Usage +#### Usage - Add to the container by calling `AddSentryTunneling();` on `IServiceCollection`. - Add the web app by calling `UseSentryTunneling();` on `IApplicationBuilder`. @@ -274,6 +288,68 @@ Sentry.init({ The [AspNetCore.Mvc sample](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Mvc) uses this approach. + +## Send Logs + +Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. + +See Microsoft.Extensions.Logging for setup details. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +using Microsoft.Extensions.Logging; + +public sealed class OrderService +{ + private readonly ILogger _logger; + + public OrderService(ILogger logger) => _logger = logger; + + public void Process() + { + _logger.LogInformation("Order processed {OrderId}", "order-123"); + _logger.LogWarning("Rate limit reached for {Endpoint}", "/api/orders"); + } +} +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. + + + +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + +## Samples + +- A [simple example](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Basic) without MVC. (**C#**) +- An [example](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Mvc) using MVC and most of the SDK features. (**C#**) +- An [example](https://github.com/sentry-demos/giraffe) using Giraffe on top of ASP.NET Core with a basic overview of available features. (**F#**) +- For [more samples](https://github.com/getsentry/sentry-dotnet-samples) of the .NET SDKs. + ## Next Steps +At this point, you should have integrated Sentry into your ASP.NET Core application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/aws-lambda/index.mdx b/docs/platforms/dotnet/guides/aws-lambda/index.mdx index 4111c1f1a8b09..75fe826abb929 100644 --- a/docs/platforms/dotnet/guides/aws-lambda/index.mdx +++ b/docs/platforms/dotnet/guides/aws-lambda/index.mdx @@ -6,16 +6,7 @@ description: "Learn about Sentry's .NET integration with AWS Lambda and ASP.NET Sentry provides an integration with AWS Lambda ASP.NET Core Server through the [Sentry.AspNetCore NuGet package](https://www.nuget.org/packages/Sentry.AspNetCore). -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - - Add the Sentry dependency: ```powershell {tabTitle:Package Manager} @@ -30,11 +21,22 @@ You can combine this integration with a logging library like `log4net`, `NLog`, ## Configure +**Error Monitoring** starts working as soon as you initialize the SDK. **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + + All `ASP.NET Core` configurations are valid here. But one configuration in particular is relevant. `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. +The snippet also turns on: + +- Tracing: via `TracesSampleRate` + +Don't need a feature? Remove its options from the snippet. + ```csharp public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction { @@ -46,15 +48,14 @@ public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFu { options.Dsn = "___PUBLIC_DSN___"; // When configuring for the first time, to see what the SDK is doing: - o.Debug = true; + options.Debug = true; // Adds request URL and headers, IP and name for users, etc. - o.SendDefaultPii = true; - // ___PRODUCT_OPTION_START___ performance - // Set TracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production + options.SendDefaultPii = true; + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. o.TracesSampleRate = 1.0; - // ___PRODUCT_OPTION_END___ performance // Required in Serverless environments options.FlushOnCompletedRequest = true; }) @@ -65,16 +66,39 @@ public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFu Check out the [Sentry ASP.NET Core](/platforms/dotnet/guides/aspnetcore/) documentation for the complete set of options. -## Verify +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Samples - Our [samples on GitHub](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.Aws.Lambda.AspNetCoreServer) demonstrate Sentry on AWS Lambda. (**C#**) ## Next Steps +At this point, you should have integrated Sentry into your AWS Lambda application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx index b70a17997070f..622c7c6f2610f 100644 --- a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx +++ b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx @@ -6,60 +6,51 @@ description: "Learn about Sentry's .NET integration with Azure Functions." Sentry provides an integration with Azure Functions through the [Sentry.Extensions.Logging](https://www.nuget.org/packages/Sentry.Extensions.Logging) and [Sentry.OpenTelemetry](https://www.nuget.org/packages/Sentry.OpenTelemetry) NuGet packages. -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - - Add the Sentry dependencies to your Azure Functions application: ```shell {tabTitle:.NET Core CLI} dotnet add package Sentry.Extensions.Logging -v {{@inject packages.version('sentry.dotnet.extensions.logging') }} -// ___PRODUCT_OPTION_START___ performance dotnet add package Sentry.OpenTelemetry -v {{@inject packages.version('sentry.dotnet.opentelemetry') }} dotnet add package OpenTelemetry dotnet add package OpenTelemetry.Extensions.Hosting dotnet add package OpenTelemetry.Instrumentation.Http - -// ___PRODUCT_OPTION_END___ ``` ```powershell {tabTitle:Package Manager} Install-Package Sentry.Extensions.Logging -Version {{@inject packages.version('sentry.dotnet.extensions.logging') }} -// ___PRODUCT_OPTION_START___ performance Install-Package Sentry.OpenTelemetry -Version {{@inject packages.version('sentry.dotnet.opentelemetry') }} -// ___PRODUCT_OPTION_END___ ``` The [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) package also provides access to the `ILogger` integration and the other core features available in the [Sentry](/platforms/dotnet/) SDK. ## Configure -The core features of Sentry are enabled by calling `AddSentry` when configuring logging. +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `Microsoft.Extensions.Logging` need `EnableLogs = true`, and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. - -Performance tracing can be enabled by adding Sentry to the OpenTelemetry `TracerProviderBuilder` and then configuring Sentry itself to use OpenTelemetry. - +The core features of Sentry are enabled by calling `AddSentry` when configuring logging. +Performance tracing can be enabled by adding Sentry to the OpenTelemetry `TracerProviderBuilder` and then configuring Sentry itself to use OpenTelemetry. For example: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` +- Logs: via `EnableLogs` + +Don't need a feature? Remove its options from the snippet. + ```csharp using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using OpenTelemetry; -// ___PRODUCT_OPTION_START___ performance using OpenTelemetry.Trace; -// ___PRODUCT_OPTION_END___ using Sentry.OpenTelemetry; var host = new HostBuilder() .ConfigureFunctionsWorkerDefaults() -// ___PRODUCT_OPTION_START___ performance .ConfigureServices(services => { services.AddOpenTelemetry().WithTracing(builder => @@ -69,17 +60,19 @@ var host = new HostBuilder() .AddHttpClientInstrumentation(); // From OpenTelemetry.Instrumentation.Http, instruments outgoing HTTP requests }); }) -// ___PRODUCT_OPTION_END___ .ConfigureLogging(logging => { logging.AddSentry(options => { options.Dsn = "___PUBLIC_DSN___"; - // ___PRODUCT_OPTION_START___ performance + options.EnableLogs = true; + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 1.0; options.UseOpenTelemetry(); // <-- Configure Sentry to use open telemetry options.DisableSentryHttpMessageHandler = true; // So Sentry doesn't also create spans for outbound HTTP requests - // ___PRODUCT_OPTION_END___ options.Debug = true; }); }) @@ -89,16 +82,64 @@ var host = new HostBuilder() await host.RunAsync(); ``` -## Verify +## Send Logs -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. + +See Microsoft.Extensions.Logging for setup details. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +using Microsoft.Extensions.Logging; + +public sealed class OrderService +{ + private readonly ILogger _logger; + + public OrderService(ILogger logger) => _logger = logger; + + public void Process() + { + _logger.LogInformation("Order processed {OrderId}", "order-123"); + _logger.LogWarning("Rate limit reached for {Endpoint}", "/api/orders"); + } +} +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Samples - [Azure Functions Sample](https://github.com/getsentry/sentry-dotnet/blob/main/samples/Sentry.Samples.OpenTelemetry.AzureFunctions/) demonstrates Sentry with Azure Functions Isolated Worker SDK. (**C#**) ## Next Steps +At this point, you should have integrated Sentry into your Azure Functions application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/blazor-server/index.mdx b/docs/platforms/dotnet/guides/blazor-server/index.mdx index d2442ee2f9c5e..cd8eb7ebb46a5 100644 --- a/docs/platforms/dotnet/guides/blazor-server/index.mdx +++ b/docs/platforms/dotnet/guides/blazor-server/index.mdx @@ -7,9 +7,6 @@ description: "Learn about Sentry's .NET integration with Blazor Interactive Serv Blazor Interactive SSR (also known as Blazor Server) runs components on the server and streams UI updates to the browser over a SignalR connection (circuit). Sentry integrates with Blazor Interactive SSR through the [Sentry.AspNetCore NuGet package](https://www.nuget.org/packages/Sentry.AspNetCore), which captures unhandled exceptions and provides optional tracing via OpenTelemetry. ## Install - - - Add the Sentry dependency to your Blazor Server application: ```shell {tabTitle:.NET Core CLI} @@ -24,8 +21,19 @@ This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extens ## Configure +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + + Initialize Sentry by calling `UseSentry` on your `WebHostBuilder`: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` + +Don't need a feature? Remove its options from the snippet. + ```csharp {filename:Program.cs} var builder = WebApplication.CreateBuilder(args); @@ -39,9 +47,11 @@ builder.WebHost.UseSentry(options => options.Debug = true; // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - // ___PRODUCT_OPTION_START___ performance + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 0.1; - // ___PRODUCT_OPTION_END___ performance }); var app = builder.Build(); @@ -56,17 +66,17 @@ app.MapFallbackToPage("/_Host"); app.Run(); ``` -## Limited Tracing on .NET 10 and Later +### Limited Tracing on .NET 10 and Later Tracing events in Blazor Server applications is challenging due to the socket based nature of communications. However, on .NET 10 and later, Blazor emits OpenTelemetry activities for circuit lifecycle events, component navigation, and UI interactions that can be used to provide some limited tracing. The [Sentry.Samples.AspNetCore.Blazor.Server](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Blazor.Server) sample project gives an example of this. -### Install OpenTelemetry +#### Install OpenTelemetry See OpenTelemetry Support for installation and setup instructions. -### Configure OpenTelemetry +#### Configure OpenTelemetry Wire up Sentry as an OpenTelemetry exporter, subscribe to the Blazor activity sources, and register helper services for circuit and breadcrumb tracking: @@ -94,6 +104,10 @@ builder.WebHost.UseSentry(options => { options.Dsn = "___PUBLIC_DSN___"; options.UseOpenTelemetry(); + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 0.1; // Rewrites /_blazor SignalR transaction names to the actual Blazor route options.AddEventProcessor(new BlazorEventProcessor()); @@ -116,7 +130,7 @@ app.MapFallbackToPage("/_Host"); app.Run(); ``` -### Circuit Lifecycle Tracking Services +#### Circuit Lifecycle Tracking Services The `BlazorSentryIntegration`, `SentryCircuitHandler`, and `BlazorEventProcessor` services shown above are not part of the Sentry integration. You can copy them from the [Blazor Server sample](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Blazor.Server/Services) into your application if they prove useful for your use case. @@ -128,16 +142,50 @@ They provide the following features: | `SentryCircuitHandler` | Hooks into circuit open/close events to track circuit lifetime and prevent memory leaks | | `BlazorEventProcessor` | Rewrites uninformative SignalR transaction names (e.g. `/_blazor`) to the actual Blazor route | -## Verify +## Send Logs + +Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Samples - This [integration with Blazor Interactive SSR](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Blazor.Server) sample demonstrates using Sentry with Blazor Server, including enhanced circuit tracking on .NET 10. (**C#**) ## Next Steps +At this point, you should have integrated Sentry into your Blazor Server application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx index 5b784b93f6c63..f240a9ce8f15c 100644 --- a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx +++ b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx @@ -7,9 +7,6 @@ description: "Learn about Sentry's .NET integration with Blazor WebAssembly." Sentry provides an integration with Blazor WebAssembly through the [Sentry.AspNetCore.Blazor.WebAssembly NuGet package](https://www.nuget.org/packages/Sentry.AspNetCore.Blazor.WebAssembly). ## Install - - - Add the Sentry dependency to your Blazor WebAssembly application: ```shell {tabTitle:.NET Core CLI} @@ -24,10 +21,22 @@ This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extens ## Configure +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `Microsoft.Extensions.Logging` need `EnableLogs = true`, and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + + Sentry integration with Blazor WebAssembly is done by calling `.UseSentry()` and specifying the options, for example: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` +- Logs: via `EnableLogs` + +Don't need a feature? Remove its options from the snippet. + ```csharp using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.Extensions.Logging; @@ -36,13 +45,16 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.UseSentry(options => { options.Dsn = "___PUBLIC_DSN___"; + options.EnableLogs = true; // When configuring for the first time, to see what the SDK is doing: options.Debug = true; // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - // ___PRODUCT_OPTION_START___ performance + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 0.1; - // ___PRODUCT_OPTION_END___ performance }); // Captures logError and higher as events @@ -51,16 +63,64 @@ builder.Logging.AddSentry(o => o.InitializeSdk = false); await builder.Build().RunAsync(); ``` -## Verify +## Send Logs -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. + +See Microsoft.Extensions.Logging for setup details. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +using Microsoft.Extensions.Logging; + +public sealed class OrderService +{ + private readonly ILogger _logger; + + public OrderService(ILogger logger) => _logger = logger; + + public void Process() + { + _logger.LogInformation("Order processed {OrderId}", "order-123"); + _logger.LogWarning("Rate limit reached for {Endpoint}", "/api/orders"); + } +} +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Samples - This [integration with Blazor WebAssembly](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.Blazor.Wasm) sample demonstrates using Sentry with Blazor WebAssembly. (**C#**) ## Next Steps +At this point, you should have integrated Sentry into your Blazor WebAssembly application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/entityframework/index.mdx b/docs/platforms/dotnet/guides/entityframework/index.mdx index da865b9022cf0..8369587d92184 100644 --- a/docs/platforms/dotnet/guides/entityframework/index.mdx +++ b/docs/platforms/dotnet/guides/entityframework/index.mdx @@ -9,23 +9,14 @@ Sentry provides an integration with `EntityFramework` through the of the [Sentry > Looking for `EntityFramework Core`? If you're targeting .NET Core 3.1 or newer, that's already built in to the main Sentry .NET SDK. It's also enabled by default for our ASP.NET or ASP.NET Core integrations, even for older targets. For other scenarios, you may need to add the `Sentry.DiagnosticSource` package and call `AddDiagnosticSourceIntegration`, [as described here](/platforms/dotnet/tracing/instrumentation/automatic-instrumentation/#diagnosticsource-integration). (The rest of this page describes our EF6 integration, not EFCore.) -## Overview of the features +**Overview of the features** - Queries as breadcrumbs - Validation errors All queries executed are added as breadcrumbs and are sent with any event which happens on the same [scope](enriching-events/scopes/). Besides that, validation errors are also included as `Extra`. -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - - ```powershell {tabTitle:Package Manager} Install-Package Sentry.EntityFramework -Version {{@inject packages.version('sentry.dotnet.ef') }} ``` @@ -36,7 +27,12 @@ dotnet add package Sentry.EntityFramework -v {{@inject packages.version('sentry. This package extends `Sentry` main SDK. That means that besides the EF features, through this package you'll also get access to all API and features available in the main `Sentry` SDK. -## Configuration +## Configure + +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + Add the Entity Framework 6 support to your project in one step: @@ -46,6 +42,12 @@ Add the Entity Framework 6 support to your project in one step: For example, configuring an ASP.NET app with _global.asax_: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` + +Don't need a feature? Remove its options from the snippet. + ```csharp {filename:global.asax} using System; using System.Configuration; @@ -63,11 +65,11 @@ public class MvcApplication : System.Web.HttpApplication options.Dsn = ConfigurationManager.AppSettings["SentryDsn"]; // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - // ___PRODUCT_OPTION_START___ performance - // Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring. - // We recommend adjusting this value in production. + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 1.0; - // ___PRODUCT_OPTION_END___ performance // Add the EntityFramework integration options.AddEntityFramework(); }); @@ -75,8 +77,6 @@ public class MvcApplication : System.Web.HttpApplication // Global error catcher protected void Application_Error() => Server.CaptureLastError(); - - // ___PRODUCT_OPTION_START___ performance protected void Application_BeginRequest() { Context.StartSentryTransaction(); @@ -86,8 +86,6 @@ public class MvcApplication : System.Web.HttpApplication { Context.FinishSentryTransaction(); } - - // ___PRODUCT_OPTION_END___ performance public override void Dispose() { _sentrySdk.Dispose(); @@ -96,12 +94,42 @@ public class MvcApplication : System.Web.HttpApplication } ``` -## Verify +## Send Logs -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Sample Check out a complete working [sample](https://github.com/getsentry/sentry-dotnet-ef/tree/master/samples/Sentry.Samples.AspNet.Mvc) to see it in action. @@ -110,4 +138,8 @@ Check out a complete working [sample](https://github.com/getsentry/sentry-dotnet ## Next Steps +At this point, you should have integrated Sentry into your Entity Framework application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/maui/index.mdx b/docs/platforms/dotnet/guides/maui/index.mdx index 1d707e3568b51..ccf74d8e586c1 100644 --- a/docs/platforms/dotnet/guides/maui/index.mdx +++ b/docs/platforms/dotnet/guides/maui/index.mdx @@ -6,7 +6,7 @@ description: "Learn about Sentry's .NET integration with .NET Multi-platform App Sentry has an integration for the [.NET Multi-platform App UI (MAUI)](https://dotnet.microsoft.com/apps/maui) through the [Sentry.Maui NuGet package](https://www.nuget.org/packages/Sentry.Maui). -## Overview of the features +**Overview of the features** - Easy MAUI integration by calling `UseSentry` on your `MauiAppBuilder` - All the features of our main [.NET SDK](/platforms/dotnet/), for your managed code @@ -18,16 +18,7 @@ Sentry has an integration for the [.NET Multi-platform App UI (MAUI)](https://do - Detailed device and runtime information passed on every event - Automatic session tracking enabled, to support [release health](/product/releases/) -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - - Add the Sentry dependency to your .NET MAUI application: ```shell {tabTitle:.NET Core CLI} @@ -42,9 +33,21 @@ This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extens ## Configure +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `Microsoft.Extensions.Logging` need `EnableLogs = true`, and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + + 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. +The snippet also turns on: + +- Tracing: via `TracesSampleRate` +- Logs: via `EnableLogs` + +Don't need a feature? Remove its options from the snippet. + ```csharp public static MauiApp CreateMauiApp() { @@ -57,6 +60,7 @@ public static MauiApp CreateMauiApp() { // The DSN is the only required setting. options.Dsn = "___PUBLIC_DSN___"; + options.EnableLogs = true; // Use debug mode if you want to see what the SDK is doing. // Debug messages are written to stdout with Console.Writeline, @@ -66,15 +70,13 @@ public static MauiApp CreateMauiApp() // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - - // ___PRODUCT_OPTION_START___ performance - // Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing. - // We recommend adjusting this value in production. + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 1.0; - // ___PRODUCT_OPTION_END___ performance // If your app doesn't have sensitive data, you can get screenshots on error events automatically - // https://docs.sentry.io/platforms/dotnet/guides/maui/configuration/options/#AttachScreenshot options.AttachScreenshot = true; // Other Sentry options can be set here. @@ -127,12 +129,60 @@ Use caution when enabling, as such values may contain personally identifiable in -## Verify +## Send Logs + +Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +See Microsoft.Extensions.Logging for setup details. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +using Microsoft.Extensions.Logging; + +public sealed class OrderService +{ + private readonly ILogger _logger; + + public OrderService(ILogger logger) => _logger = logger; + + public void Process() + { + _logger.LogInformation("Order processed {OrderId}", "order-123"); + _logger.LogWarning("Rate limit reached for {Endpoint}", "/api/orders"); + } +} +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Next Steps +At this point, you should have integrated Sentry into your .NET MAUI application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/winforms/index.mdx b/docs/platforms/dotnet/guides/winforms/index.mdx index 166143d0461d5..17ca0dc965318 100644 --- a/docs/platforms/dotnet/guides/winforms/index.mdx +++ b/docs/platforms/dotnet/guides/winforms/index.mdx @@ -6,20 +6,16 @@ og_image: /og-images/platforms-dotnet-guides-winforms.png Sentry's .NET SDK works with WinForms applications through the [Sentry NuGet package](https://www.nuget.org/packages/Sentry). It works with WinForms apps running on .NET Framework 4.6.2, .NET Core 3.0, or higher. -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - - ## Configure +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + + After adding the NuGet package, the SDK should be initialized in the program's main entry point, before launching any forms or performing significant work. The options for initialization vary by language. ### C# Initialization @@ -31,6 +27,12 @@ You should also set `Application.SetUnhandledExceptionMode(UnhandledExceptionMod A complete example of the recommended startup is as follows: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` + +Don't need a feature? Remove its options from the snippet. + ```csharp using System; using System.Windows.Forms; @@ -63,14 +65,12 @@ namespace WindowsFormsApp1 Debug = true, // Adds request URL and headers, IP and name for users, etc. - options.SendDefaultPii = true; - - // ___PRODUCT_OPTION_START___ performance - // Set traces_sample_rate to 1.0 to capture 100% of transactions for tracing. - // We recommend adjusting this value in production. + SendDefaultPii = true, + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. TracesSampleRate = 1.0, - - // ___PRODUCT_OPTION_END___ performance // Enable Global Mode since this is a client app IsGlobalModeEnabled = true, @@ -226,16 +226,50 @@ Namespace My End Namespace ``` -## Verify +## Send Logs + +Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Resources [Discussion on GitHub `Application.SetUnhandledExceptionMode`](https://github.com/getsentry/sentry-dotnet/issues/176) ## Next Steps +At this point, you should have integrated Sentry into your WinForms application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/winui/index.mdx b/docs/platforms/dotnet/guides/winui/index.mdx index a0c231388bbbd..8579b0c0c69cc 100644 --- a/docs/platforms/dotnet/guides/winui/index.mdx +++ b/docs/platforms/dotnet/guides/winui/index.mdx @@ -5,19 +5,15 @@ description: "Learn about using Sentry's .NET SDK with the Windows UI Library" Sentry's .NET SDK works with Windows UI Library applications through the [Sentry NuGet package](https://www.nuget.org/packages/Sentry). -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install + - +## Configure - +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. -## Configure (Without Trimming) If you don't have [Trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-8-0) enabled when publishing your application then all you need to do is [initialize the SDK with `SentrySdk.Init`](/platforms/dotnet/) in the constructor of your application class (usually `App.xaml.cs`). Sentry's integration for WinUI will automatically capture any unhandled exceptions in your application and send these to Sentry. @@ -30,7 +26,11 @@ Do not initialize the SDK in the `OnLaunched` event of the application or the `H In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. +The snippet also turns on: + +- Tracing: via `TracesSampleRate` + +Don't need a feature? Remove its options from the snippet. ```csharp using Sentry.Protocol; @@ -50,12 +50,12 @@ sealed partial class App : Application // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - // ___PRODUCT_OPTION_START___ performance - // Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing. - // We recommend adjusting this value in production. + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 1.0; - // ___PRODUCT_OPTION_END___ performance // Enable Global Mode since this is a client app. options.IsGlobalModeEnabled = true; @@ -71,7 +71,7 @@ sealed partial class App : Application } ``` -## Configure (With Trimming) +### Configure With Trimming If you have [Trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-8-0) enabled when publishing your application then, in addition to [initializing the SDK with `SentrySdk.Init`](/platforms/dotnet/), you must also configure an UnhandledException handler in the constructor of your application class (usually `App.xaml.cs`). @@ -102,12 +102,12 @@ sealed partial class App : Application // Adds request URL and headers, IP and name for users, etc. o.SendDefaultPii = true; - // ___PRODUCT_OPTION_START___ performance - // Set TracesSampleRate to 1.0 to capture 100% of transactions for tracing. - // We recommend adjusting this value in production. + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. o.TracesSampleRate = 1.0; - // ___PRODUCT_OPTION_END___ performance // Enable Global Mode since this is a client app. o.IsGlobalModeEnabled = true; @@ -151,12 +151,46 @@ sealed partial class App : Application } ``` -## Verify +## Send Logs + +Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Next Steps +At this point, you should have integrated Sentry into your WinUI application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/wpf/index.mdx b/docs/platforms/dotnet/guides/wpf/index.mdx index 436f99010e3a3..cb603f1f49048 100644 --- a/docs/platforms/dotnet/guides/wpf/index.mdx +++ b/docs/platforms/dotnet/guides/wpf/index.mdx @@ -5,25 +5,27 @@ description: "Learn more about how Sentry's .NET SDK works with Windows Presenta Sentry's .NET SDK works with Windows Presentation Foundation applications through the [Sentry NuGet package](https://www.nuget.org/packages/Sentry). It works with WPF apps running on .NET Framework 4.6.2, .NET Core 3.0 or higher. -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - - ## Configure +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + + In addition to [initializing the SDK with `SentrySdk.Init`](/platforms/dotnet/), you must configure the WPF specific error handler. The SDK automatically handles `AppDomain.UnhandledException`. On WPF, for production apps (when no debugger is attached), WPF catches exception to show the dialog to the user. You can also configure your app to capture those exceptions before the dialog shows up: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` + +Don't need a feature? Remove its options from the snippet. + ```csharp using System.Windows; @@ -41,13 +43,11 @@ public partial class App : Application // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - - // ___PRODUCT_OPTION_START___ performance - // Set traces_sample_rate to 1.0 to capture 100% of transactions for tracing. - // We recommend adjusting this value in production. + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 1.0; - - // ___PRODUCT_OPTION_END___ performance // Enable Global Mode since this is a client app options.IsGlobalModeEnabled = true; @@ -66,12 +66,46 @@ public partial class App : Application } ``` -## Verify +## Send Logs + +Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Next Steps +At this point, you should have integrated Sentry into your WPF application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/guides/xamarin/index.mdx b/docs/platforms/dotnet/guides/xamarin/index.mdx index e4aca0e0cd367..602ffc7d54d58 100644 --- a/docs/platforms/dotnet/guides/xamarin/index.mdx +++ b/docs/platforms/dotnet/guides/xamarin/index.mdx @@ -19,13 +19,21 @@ The SDK is compatible with the following versions or higher: ## Configure -After you've completed setting up a project in Sentry, Sentry will give you a value which we call a DSN or Data Source Name. It looks a lot like a standard URL, but it's just a representation of the configuration required by the Sentry SDK. It consists of a few pieces, including the protocol, public key, the server address, and the project identifier. +**Error Monitoring** starts working as soon as you initialize the SDK. **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. - +After you've completed setting up a project in Sentry, Sentry will give you a value which we call a DSN or Data Source Name. It looks a lot like a standard URL, but it's just a representation of the configuration required by the Sentry SDK. It consists of a few pieces, including the protocol, public key, the server address, and the project identifier. You should initialize the SDK as early as possible, for an example, the start of OnCreate on MainActivity for Android, and, the top of FinishedLaunching on AppDelegate for iOS). +The snippet also turns on: + +- Tracing: via `TracesSampleRate` + +Don't need a feature? Remove its options from the snippet. + ```csharp SentryXamarin.Init(options => { @@ -36,27 +44,16 @@ SentryXamarin.Init(options => options.Debug = true; // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - // ___PRODUCT_OPTION_START___ performance - // Set TracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 1.0; - // ___PRODUCT_OPTION_END___ performance }); // App code ``` -## Verify - -Great! Now that you've completed setting up the SDK, maybe you want to quickly test out how Sentry works. Start by capturing an exception: - - - -All you need to do is to [initialize the SDK with `SentryXamarin.Init`](../../), you will not need any additional changes to get the SDK ready to go. - -The SDK automatically handles `AppDomain.UnhandledException` and `Application.UnhandledException`, so you'll not need to worry about trying to Catch Unhandled Exceptions. - ### Xamarin Options The following options are only going to be valid during the SDK initialization. @@ -85,6 +82,32 @@ Note that personally identifiable information (PII) might be included in the scr Disables the automatic Logging of internal Warnings that comes from Xamarin Forms. + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. + + + +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Troubleshooting For information about Troubleshooting, please visit the [troubleshooting](troubleshooting/) page. @@ -95,4 +118,8 @@ For information about Troubleshooting, please visit the [troubleshooting](troubl ## Next Steps +At this point, you should have integrated Sentry into your Xamarin application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/docs/platforms/dotnet/index.mdx b/docs/platforms/dotnet/index.mdx index 45a64bc5f8916..17c92b143214e 100644 --- a/docs/platforms/dotnet/index.mdx +++ b/docs/platforms/dotnet/index.mdx @@ -24,47 +24,34 @@ You can use these instructions to run Sentry in an app running on: If you're using a framework, such as ASP.NET Core or MAUI, please select the framework on the drop down on the top left. -## Features - -In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/profiling/). - -Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. - ## Install - - -Sentry captures data by using an SDK within your application's runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works. +Install the `Sentry` NuGet package to add the SDK. This guide also includes profiling setup for supported .NET targets, which requires `Sentry.Profiling`. -Install the **NuGet** package to add the Sentry dependency: - - - - ```shell {tabTitle:.NET Core CLI} - dotnet add package Sentry -v {{@inject packages.version('sentry.dotnet') }} - ``` +```shell {tabTitle:.NET Core CLI} +dotnet add package Sentry -v {{@inject packages.version('sentry.dotnet') }} +dotnet add package Sentry.Profiling -v {{@inject packages.version('sentry.dotnet.profiling') }} +``` - ```powershell {tabTitle:Package Manager} - Install-Package Sentry. -Version {{@inject packages.version('sentry.dotnet') }} - ``` +```powershell {tabTitle:Package Manager} +Install-Package Sentry -Version {{@inject packages.version('sentry.dotnet') }} +Install-Package Sentry.Profiling -Version {{@inject packages.version('sentry.dotnet.profiling') }} +``` +## Configure - +**Error Monitoring** starts working as soon as you call `SentrySdk.Init()`. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). - +This guide also enables **Tracing** and **Profiling**. - ```shell {tabTitle:.NET Core CLI} - dotnet add package Sentry.Profiling -v {{@inject packages.version('sentry.dotnet.profiling') }} - ``` - ```powershell {tabTitle:Package Manager} - Install-Package Sentry.Profiling -Version {{@inject packages.version('sentry.dotnet.profiling') }} - ``` +To capture all errors, even the one during the startup of your application, you should initialize the Sentry .NET SDK as soon as possible. - +The snippet also turns on: -## Configure +- Tracing: via `TracesSampleRate` +- Profiling: via `ProfilesSampleRate` and the profiling integration -To capture all errors, even the one during the startup of your application, you should initialize the Sentry .NET SDK as soon as possible. +Don't need a feature? Remove its options from the snippet. ```csharp SentrySdk.Init(options => @@ -73,23 +60,58 @@ SentrySdk.Init(options => options.Debug = true; // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - // ___PRODUCT_OPTION_START___ performance - // A fixed sample rate of 1.0 - 100% of all transactions are getting sent + // Enables Tracing. + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. options.TracesSampleRate = 1.0f; - // ___PRODUCT_OPTION_END___ performance - // ___PRODUCT_OPTION_START___ profiling - // A sample rate for profiling - this is relative to TracesSampleRate + // Enables Profiling. + // Set to 1.0 to profile 100% of captured transactions. options.ProfilesSampleRate = 1.0f; - // ___PRODUCT_OPTION_END___ profiling + options.AddProfilingIntegration(); }); ``` -## Verify +## Send Logs + +Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics + +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Next Steps +At this point, you should have integrated Sentry into your .NET application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) diff --git a/platform-includes/getting-started-verify/dotnet.mdx b/platform-includes/getting-started-verify/dotnet.mdx index 8ade5cdefb075..d40fb0c6bf5a1 100644 --- a/platform-includes/getting-started-verify/dotnet.mdx +++ b/platform-includes/getting-started-verify/dotnet.mdx @@ -1,17 +1,7 @@ ```csharp -try -{ - throw null; -} -catch (Exception ex) -{ - SentrySdk.CaptureException(ex); -} +SentrySdk.CaptureException(new System.Exception("Sentry test exception")); ``` ```fsharp -try - raise <| NullReferenceException () -with ex -> - SentrySdk.CaptureException(ex) |> ignore +SentrySdk.CaptureException(System.Exception("Sentry test exception")) |> ignore ``` diff --git a/platform-includes/getting-started-verify/dotnet.xamarin.mdx b/platform-includes/getting-started-verify/dotnet.xamarin.mdx index d996892afff2a..56ea216099335 100644 --- a/platform-includes/getting-started-verify/dotnet.xamarin.mdx +++ b/platform-includes/getting-started-verify/dotnet.xamarin.mdx @@ -1,5 +1,5 @@ -You can verify Sentry is capturing unhandled exceptions by raising an exception. For example, you can use the following snippet to raise a `NullReferenceException`: +You can verify Sentry is capturing exceptions by sending a test exception: ```csharp -throw null; +SentrySdk.CaptureException(new System.Exception("Sentry test exception")); ``` From 4d6dfbc837a254edeaba458857a28a226ff9f8b1 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:20:46 +0000 Subject: [PATCH 2/6] ref(docs): Keep thrown exceptions in shared .NET verify snippets Unthrown exceptions passed to CaptureException carry no stack trace, and these includes also render on .NET guides outside this change. Co-Authored-By: Shannon Anahata --- .../getting-started-verify/dotnet.mdx | 14 ++++++++++++-- .../getting-started-verify/dotnet.xamarin.mdx | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/platform-includes/getting-started-verify/dotnet.mdx b/platform-includes/getting-started-verify/dotnet.mdx index d40fb0c6bf5a1..8ade5cdefb075 100644 --- a/platform-includes/getting-started-verify/dotnet.mdx +++ b/platform-includes/getting-started-verify/dotnet.mdx @@ -1,7 +1,17 @@ ```csharp -SentrySdk.CaptureException(new System.Exception("Sentry test exception")); +try +{ + throw null; +} +catch (Exception ex) +{ + SentrySdk.CaptureException(ex); +} ``` ```fsharp -SentrySdk.CaptureException(System.Exception("Sentry test exception")) |> ignore +try + raise <| NullReferenceException () +with ex -> + SentrySdk.CaptureException(ex) |> ignore ``` diff --git a/platform-includes/getting-started-verify/dotnet.xamarin.mdx b/platform-includes/getting-started-verify/dotnet.xamarin.mdx index 56ea216099335..d996892afff2a 100644 --- a/platform-includes/getting-started-verify/dotnet.xamarin.mdx +++ b/platform-includes/getting-started-verify/dotnet.xamarin.mdx @@ -1,5 +1,5 @@ -You can verify Sentry is capturing exceptions by sending a test exception: +You can verify Sentry is capturing unhandled exceptions by raising an exception. For example, you can use the following snippet to raise a `NullReferenceException`: ```csharp -SentrySdk.CaptureException(new System.Exception("Sentry test exception")); +throw null; ``` From 3ef8f33a9769b0c585c346ff06a5b5764a376ad4 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 00:27:11 +0000 Subject: [PATCH 3/6] fix(docs): Fix broken Logs and integration links in .NET quick starts PlatformLink prefixes the current guide, so integration guide links resolved under the wrong path, and EnableLogs lives on the Logs page rather than a logs/options page. --- docs/platforms/dotnet/guides/aspnet/index.mdx | 4 ++-- docs/platforms/dotnet/guides/aspnetcore/index.mdx | 4 ++-- docs/platforms/dotnet/guides/azure-functions-worker/index.mdx | 4 ++-- docs/platforms/dotnet/guides/blazor-webassembly/index.mdx | 4 ++-- docs/platforms/dotnet/guides/maui/index.mdx | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/platforms/dotnet/guides/aspnet/index.mdx b/docs/platforms/dotnet/guides/aspnet/index.mdx index 9137143b1cf56..37493121ef642 100644 --- a/docs/platforms/dotnet/guides/aspnet/index.mdx +++ b/docs/platforms/dotnet/guides/aspnet/index.mdx @@ -33,7 +33,7 @@ You configure the SDK in the `Global.asax.cs`: The snippet also turns on: - Tracing: via `TracesSampleRate` -- Logs from logging integrations: via `EnableLogs` +- Logs from logging integrations: via `EnableLogs` Don't need a feature? Remove its options from the snippet. @@ -120,7 +120,7 @@ options.AddAspNet(RequestSize.Always); Use `SentrySdk.Logger` to send logs at different levels without an additional option. If you also send logs through an integration, set `EnableLogs = true` in the initialization snippet. -If you use Serilog, NLog, or log4net, see the documented Serilog, NLog, and log4net integrations. +If you use Serilog, NLog, or log4net, see the documented [Serilog](/platforms/dotnet/guides/serilog/), [NLog](/platforms/dotnet/guides/nlog/), and [log4net](/platforms/dotnet/guides/log4net/) integrations. See Set Up Logs for all available logging methods and formatting options. diff --git a/docs/platforms/dotnet/guides/aspnetcore/index.mdx b/docs/platforms/dotnet/guides/aspnetcore/index.mdx index 30435f6359c60..953b9886c775c 100644 --- a/docs/platforms/dotnet/guides/aspnetcore/index.mdx +++ b/docs/platforms/dotnet/guides/aspnetcore/index.mdx @@ -36,7 +36,7 @@ When configuring the SDK via the frameworks configuration system, it's possible The snippet also turns on: - Tracing: via `TracesSampleRate` -- Logs: via `EnableLogs` +- Logs: via `EnableLogs` Don't need a feature? Remove its options from the snippet. @@ -293,7 +293,7 @@ The [AspNetCore.Mvc sample](https://github.com/getsentry/sentry-dotnet/tree/main Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. -See Microsoft.Extensions.Logging for setup details. +See [Microsoft.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) for setup details. See Set Up Logs for all available logging methods and formatting options. diff --git a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx index 622c7c6f2610f..4fc569dc4beeb 100644 --- a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx +++ b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx @@ -38,7 +38,7 @@ For example: The snippet also turns on: - Tracing: via `TracesSampleRate` -- Logs: via `EnableLogs` +- Logs: via `EnableLogs` Don't need a feature? Remove its options from the snippet. @@ -86,7 +86,7 @@ await host.RunAsync(); Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. -See Microsoft.Extensions.Logging for setup details. +See [Microsoft.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) for setup details. See Set Up Logs for all available logging methods and formatting options. diff --git a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx index f240a9ce8f15c..8d8bd7a07fae9 100644 --- a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx +++ b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx @@ -33,7 +33,7 @@ Sentry integration with Blazor WebAssembly is done by calling `.UseSentry()` and The snippet also turns on: - Tracing: via `TracesSampleRate` -- Logs: via `EnableLogs` +- Logs: via `EnableLogs` Don't need a feature? Remove its options from the snippet. @@ -67,7 +67,7 @@ await builder.Build().RunAsync(); Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. -See Microsoft.Extensions.Logging for setup details. +See [Microsoft.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) for setup details. See Set Up Logs for all available logging methods and formatting options. diff --git a/docs/platforms/dotnet/guides/maui/index.mdx b/docs/platforms/dotnet/guides/maui/index.mdx index ccf74d8e586c1..df854b1f44fa2 100644 --- a/docs/platforms/dotnet/guides/maui/index.mdx +++ b/docs/platforms/dotnet/guides/maui/index.mdx @@ -44,7 +44,7 @@ In your `MauiProgram.cs` file, call `UseSentry` on your `MauiAppBuilder`, and in The snippet also turns on: - Tracing: via `TracesSampleRate` -- Logs: via `EnableLogs` +- Logs: via `EnableLogs` Don't need a feature? Remove its options from the snippet. @@ -133,7 +133,7 @@ Use caution when enabling, as such values may contain personally identifiable in Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. -See Microsoft.Extensions.Logging for setup details. +See [Microsoft.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) for setup details. See Set Up Logs for all available logging methods and formatting options. From c10390017abffc9772057b8d68025ee1f6498061 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 20:29:18 +0000 Subject: [PATCH 4/6] feat(docs): Apply new quick start template to .NET Android, Apple, and Google Cloud Functions quick start guides Co-Authored-By: Shannon Anahata --- .../platforms/dotnet/guides/android/index.mdx | 84 ++++++++++++---- docs/platforms/dotnet/guides/apple/index.mdx | 85 +++++++++++++--- .../guides/google-cloud-functions/index.mdx | 97 ++++++++++++------- 3 files changed, 202 insertions(+), 64 deletions(-) diff --git a/docs/platforms/dotnet/guides/android/index.mdx b/docs/platforms/dotnet/guides/android/index.mdx index a22d3c50e1813..25c46f3c4eed7 100644 --- a/docs/platforms/dotnet/guides/android/index.mdx +++ b/docs/platforms/dotnet/guides/android/index.mdx @@ -6,20 +6,6 @@ description: "Learn about Sentry's .NET integration with .NET for Android" Sentry supports [.NET for Android](https://learn.microsoft.com/dotnet/android/getting-started/installation/) directly from the [Sentry NuGet package](https://www.nuget.org/packages/Sentry). -## Overview of the features - -- All the features of our main [.NET SDK](/platforms/dotnet/), for your managed code -- Attach LogCat logs to events -- Java crash reporting for Android, leveraging our [Android SDK](/platforms/android/) including: - - [Capture Application Not Responding (ANR) errors](/platforms/android/configuration/app-not-respond/) when the app is unresponsive - - Automatically [attach screenshots to Java exceptions](/platforms/android/enriching-events/screenshots/) - - Automatic breadcrumbs for Activity lifecycle, App lifecycle, System and Network events and User Interactions - - Automatic [Activity lifecycle tracing](/platforms/android/tracing/instrumentation/automatic-instrumentation/#activity-instrumentation) and [User Interaction tracing](/platforms/android/performance/instrumentation/automatic-instrumentation/#user-interaction-instrumentation) - - Device Root checking -- Native crash reporting for Android, leveraging our [Android NDK](/platforms/android/configuration/using-ndk/) -- Automatic session tracking and [release health](/product/releases/) -- _Session Replay for Android_ (currently experimental) - ## Install Add the Sentry dependency to your .NET for Android application: @@ -34,8 +20,31 @@ Install-Package Sentry -Version {{@inject packages.version('sentry.dotnet') }} ## Configure +**Error Monitoring** starts working as soon as you call `SentrySdk.Init()`. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing** and **Session Replay** (experimental). + +On .NET for Android, you also get: + +- All the features of our main [.NET SDK](/platforms/dotnet/), for your managed code +- LogCat logs attached to events +- Java crash reporting for Android, leveraging our [Android SDK](/platforms/android/) including: + - [Capture Application Not Responding (ANR) errors](/platforms/android/configuration/app-not-respond/) when the app is unresponsive + - Automatically [attach screenshots to Java exceptions](/platforms/android/enriching-events/screenshots/) + - Automatic breadcrumbs for Activity lifecycle, App lifecycle, System and Network events and User Interactions + - Automatic [Activity lifecycle tracing](/platforms/android/tracing/instrumentation/automatic-instrumentation/#activity-instrumentation) and [User Interaction tracing](/platforms/android/tracing/instrumentation/automatic-instrumentation/#user-interaction-instrumentation) + - Device Root checking +- Native crash reporting for Android, leveraging our [Android NDK](/platforms/android/configuration/using-ndk/) +- Automatic session tracking and [release health](/product/releases/) + In your `MainActivity.cs` file, call `SentrySdk.Init` in the `OnCreate` event and include any options you would like to set. The `Dsn` is the only required parameter. +The snippet also turns on: + +- Tracing: via `TracesSampleRate` +- Session Replay: via `Native.ExperimentalOptions.SessionReplay` + +Don't need a feature? Remove its options from the snippet. ```csharp [Activity(Label = "@string/app_name", MainLauncher = true)] @@ -47,6 +56,10 @@ public class MainActivity : Activity { options.Dsn = "___PUBLIC_DSN___"; options.SendDefaultPii = true; // adds the user's IP address automatically + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + options.TracesSampleRate = 1.0; #if DEBUG // Log debug information about the Sentry SDK options.Debug = true; @@ -95,7 +108,7 @@ The .NET for Android integration is part of [Sentry](/platforms/dotnet/). Please Android-specific options are described below. For configuration of the embedded Sentry Android SDK, see Android Native Options. -### LogCatIntegration +#### LogCatIntegration Can be set to control whether when LogCat logs are attached to events. It can be set to one of the following values: @@ -112,18 +125,53 @@ Use caution when enabling `LogCatIntegrationType.All`, as this may result in a l -### LogCatMaxLines +#### LogCatMaxLines The maximum number of lines to read from LogCat logs. The default value is 1000. -## Verify +## Send Logs + +Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Next Steps +At this point, you should have integrated Sentry into your .NET for Android application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) +- Configure the embedded Android SDK with Android Native Options diff --git a/docs/platforms/dotnet/guides/apple/index.mdx b/docs/platforms/dotnet/guides/apple/index.mdx index 1e22ffc0d3b26..c5e0cb7612e3c 100644 --- a/docs/platforms/dotnet/guides/apple/index.mdx +++ b/docs/platforms/dotnet/guides/apple/index.mdx @@ -6,17 +6,6 @@ description: "Learn about Sentry's .NET integration with .NET for iOS, macOS, an Sentry supports [.NET for iOS, macOS, and Mac Catalyst](https://learn.microsoft.com/dotnet/ios/) directly from the [Sentry NuGet package](https://www.nuget.org/packages/Sentry). -## Overview of the features - -- All the features of our main [.NET SDK](/platforms/dotnet/), for your managed code -- Native crash reporting for Apple platforms, leveraging our [Cocoa SDK](/platforms/apple/) including: - - Automatically [attach screenshots to Native exceptions](/platforms/apple/guides/ios/configuration/options/#attach-screenshot) - - Detect [App Hangs](/platforms/apple/configuration/app-hangs/) - - [Automatic performance tracing](/platforms/apple/performance/) - - [Automatic breadcrumbs](/platforms/apple/enriching-events/breadcrumbs/#automatic-breadcrumbs) - - [Swizzling](/platforms/apple/configuration/swizzling/) -- Automatic session tracking and [release health](/product/releases/) - ## Install Add the Sentry dependency to your .NET for iOS, macOS, and/or Mac Catalyst application: @@ -31,8 +20,30 @@ Install-Package Sentry -Version {{@inject packages.version('sentry.dotnet') }} ## Configure +**Error Monitoring** starts working as soon as you call `SentrySdk.Init()`. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**, **Profiling**, and **Session Replay** (experimental). + +On .NET for iOS, macOS, and Mac Catalyst, you also get: + +- All the features of our main [.NET SDK](/platforms/dotnet/), for your managed code +- Native crash reporting for Apple platforms, leveraging our [Cocoa SDK](/platforms/apple/) including: + - Automatically [attach screenshots to Native exceptions](/platforms/apple/guides/ios/configuration/options/#attachScreenshot) + - Detect [App Hangs](/platforms/apple/configuration/app-hangs/) + - [Automatic performance tracing](/platforms/apple/tracing/) + - [Automatic breadcrumbs](/platforms/apple/enriching-events/breadcrumbs/#automatic-breadcrumbs) + - [Swizzling](/platforms/apple/configuration/swizzling/) +- Automatic session tracking and [release health](/product/releases/) + In your `AppDelegate.cs` file, call `SentrySdk.Init` in the `FinishedLaunching` event and include any options you would like to set. The `Dsn` is the only required parameter. +The snippet also turns on: + +- Tracing: via `TracesSampleRate` +- Profiling: via `ProfilesSampleRate`. On iOS and Mac Catalyst, the SDK adds the native profiling integration automatically, so you don't need the `Sentry.Profiling` package. +- Session Replay: via `Native.ExperimentalOptions.SessionReplay` + +Don't need a feature? Remove its options from the snippet. ```csharp [Register("AppDelegate")] @@ -45,6 +56,13 @@ public class AppDelegate : UIApplicationDelegate { options.Dsn = "___PUBLIC_DSN___"; options.SendDefaultPii = true; // adds the user's IP address automatically + // Enables Tracing. + // Set to 1.0 to capture 100% of spans for tracing. + // We recommend reducing this value in production. + options.TracesSampleRate = 1.0; + // Enables Profiling. + // Set to 1.0 to profile 100% of captured transactions. + options.ProfilesSampleRate = 1.0; #if DEBUG // Log debug information about the Sentry SDK options.Debug = true; @@ -57,6 +75,10 @@ public class AppDelegate : UIApplicationDelegate // https://docs.sentry.io/platforms/apple/guides/ios/configuration/options/#attachScreenshot options.Native.AttachScreenshot = true; + // Session Replay is currently available via the ExperimentalOptions + options.Native.ExperimentalOptions.SessionReplay.OnErrorSampleRate = 1.0; + options.Native.ExperimentalOptions.SessionReplay.SessionSampleRate = 1.0; + options.SetBeforeSend(evt => { if (evt.Exception?.Message.Contains("Something you don't care want logged?") ?? false) @@ -73,6 +95,8 @@ public class AppDelegate : UIApplicationDelegate Console.WriteLine(e); }; }); + + return true; } } ``` @@ -85,12 +109,47 @@ The .NET for iOS, macOS, and Mac Catalyst integration is part of [Sentry](/platf For configuration of the embedded Sentry Cocoa SDK, see Apple Native Options. -## Verify +## Send Logs + +Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +SentrySdk.Logger.LogInfo("Order processed"); +SentrySdk.Logger.LogWarning("Rate limit reached for /api/orders"); +``` + +## Send Application Metrics -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. +### View Captured Data in Sentry + +Open your Sentry project to view the captured event. + ## Next Steps +At this point, you should have integrated Sentry into your .NET for iOS, macOS, or Mac Catalyst application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) +- Configure the embedded Cocoa SDK with Apple Native Options diff --git a/docs/platforms/dotnet/guides/google-cloud-functions/index.mdx b/docs/platforms/dotnet/guides/google-cloud-functions/index.mdx index 31193f41c65ed..582956bbfc65d 100644 --- a/docs/platforms/dotnet/guides/google-cloud-functions/index.mdx +++ b/docs/platforms/dotnet/guides/google-cloud-functions/index.mdx @@ -6,29 +6,6 @@ description: "Learn about Sentry's .NET integration with Google Cloud Functions. Sentry provides an integration with `Google Cloud Functions` through the [Sentry.Google.Cloud.Functions NuGet package](https://www.nuget.org/packages/sentry.google.cloud.functions). -## Overview of the Features - -- Easy Google Cloud Functions integration, single line: `[assembly: FunctionsStartup(typeof(SentryStartup))]` -- Captures unhandled exceptions in the middleware pipeline -- Captures exceptions handled by the framework `UseExceptionHandler` -- Captures process-wide unhandled exceptions (AppDomain) -- Captures `LogError` or `LogCritical` -- Any event sent will include relevant application log messages -- RequestId as tag -- URL as tag -- Environment is automatically set (IHostingEnvironment) -- Request payload can be captured if opt-in -- Support for EventProcessors registered with DI -- Support for ExceptionProcessors registered with DI -- Supports configuration system (bind to `SentryAspNetCoreOptions`) -- Server OS info sent -- Server Runtime info sent -- Request headers sent -- HTTP Proxy configuration -- Request body compressed -- Event flooding protection (429 retry-after and internal bound queue) -- Assembly Strong named - ## Install Add the Sentry dependency: @@ -59,13 +36,44 @@ Messages logged from assemblies with the name starting with `Sentry` will not ge ## Configure +**Error Monitoring** starts working as soon as you initialize the SDK. **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Application Metrics](#send-application-metrics-). + +This guide also enables **Tracing**. + +The `Sentry.Google.Cloud.Functions` integration also gives you: + +- Easy Google Cloud Functions integration, single line: `[assembly: FunctionsStartup(typeof(SentryStartup))]` +- Captures unhandled exceptions in the middleware pipeline +- Captures exceptions handled by the framework `UseExceptionHandler` +- Captures process-wide unhandled exceptions (AppDomain) +- Captures `LogError` or `LogCritical` +- Any event sent will include relevant application log messages +- RequestId as tag +- URL as tag +- Environment is automatically set (IHostingEnvironment) +- Request payload can be captured if opt-in +- Support for EventProcessors registered with DI +- Support for ExceptionProcessors registered with DI +- Supports configuration system (bind to `SentryAspNetCoreOptions`) +- Server OS info sent +- Server Runtime info sent +- Request headers sent +- HTTP Proxy configuration +- Request body compressed +- Event flooding protection (429 retry-after and internal bound queue) +- Assembly Strong named + The simplest way to configure the `Sentry.Google.Cloud.Functions` package is by setting up your Sentry configuration into `appsettings.json` using the assembly method `FunctionsStartup` to include the type `SentryStartup`. -For example: +The snippet also turns on: + +- Tracing: via `TracesSampleRate` +Don't need a feature? Remove its options from the snippet. ```json {filename:appsettings.json} +{ "Sentry": { "Dsn": "___PUBLIC_DSN___", "MaxRequestBodySize": "Always", @@ -74,12 +82,16 @@ For example: "MinimumEventLevel": "Warning", "AttachStackTrace": true, "Debug": true, - "DiagnosticsLevel": "Error" + "DiagnosticLevel": "Error", + "TracesSampleRate": 1.0 } +} ``` > An example of some of the options that can be configured via `appsettings.json`. +Setting `TracesSampleRate` to `1.0` captures 100% of spans. We recommend reducing this value in production. + To load the configurations, you will need to use the assembly `[assembly: FunctionsStartup(typeof(SentryStartup))]`. After being initialized, the framework automatically loads `appsettings.json` and environment variables, binding to `SentryAspNetCoreOptions`. ```csharp {tabTitle:Function.cs} @@ -124,11 +136,11 @@ public class CustomOptions : FunctionsStartup > Example modifying all events before they are sent to avoid server names being reported. -## Dependency Injection +### Dependency Injection Much of the behavior of the Google cloud functions integration with Sentry can be customized by using the frameworks dependency injection system. That is done by registering your own implementation of some of the exposed abstraction inside of `FunctionsStartup`. -### Capturing the Affected User +#### Capturing the Affected User When opting in to `SendDefaultPii`, the SDK will automatically read the user from the request by inspecting `HttpContext.User`. Default claim values like `NameIdentifier` for the _Id_ will be used. @@ -152,21 +164,40 @@ public class UserFactoryStartup : FunctionsStartup } ``` -### Options & Initialization +### Options and Initialization As previously mentioned, this package is a wrapper around [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/), [Sentry.AspNetCore](/platforms/dotnet/guides/aspnetcore/) and [Sentry](/platforms/dotnet/). Please refer to the documentation of these packages to get the options that are defined at those levels. -## Verify +## Send Application Metrics -This snippet includes an intentional error, so you can test that everything is working as soon as you set it up. +Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. + +See Set Up Metrics for all available metric types and configuration options. + +```csharp +SentrySdk.Metrics.EmitCounter("button_click", 5, + [new KeyValuePair("browser", "Firefox")]); +SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("page", "/home")]); +SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, + [new KeyValuePair("endpoint", "/api/orders")]); +``` + +## Verify Your Setup + +Let's test your setup and confirm that data reaches your Sentry project. -## Samples +### View Captured Data in Sentry -- [Google Cloud Functions sample](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.Google.Cloud.Functions) -- For [more samples](https://github.com/getsentry/sentry-dotnet-samples) of the .NET SDKs. +Open your Sentry project to view the captured event. ## Next Steps +At this point, you should have integrated Sentry into your Google Cloud Functions application. Here's what to explore next: + - Explore [practical guides](/get-started/guides/) on what to monitor, log, track, and investigate after setup +- Learn how to [manually capture errors](/platforms/dotnet/usage/) +- Explore [Tracing](/platforms/dotnet/tracing/) +- Check out the [Google Cloud Functions sample](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.Google.Cloud.Functions), or browse [more samples](https://github.com/getsentry/sentry-dotnet-samples) of the .NET SDKs From 6df07df2effe85727347a9970f670dcd5c78a1ed Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 20:31:23 +0000 Subject: [PATCH 5/6] fix(docs): Remove duplicate tracing comments and fix AWS Lambda options variable in .NET quick starts Co-Authored-By: Shannon Anahata --- docs/platforms/dotnet/guides/aspnet/index.mdx | 1 - docs/platforms/dotnet/guides/aspnetcore/index.mdx | 5 ----- docs/platforms/dotnet/guides/aws-lambda/index.mdx | 3 +-- .../platforms/dotnet/guides/azure-functions-worker/index.mdx | 1 - docs/platforms/dotnet/guides/blazor-server/index.mdx | 2 -- docs/platforms/dotnet/guides/blazor-webassembly/index.mdx | 1 - docs/platforms/dotnet/guides/entityframework/index.mdx | 1 - docs/platforms/dotnet/guides/maui/index.mdx | 1 - docs/platforms/dotnet/guides/winforms/index.mdx | 1 - docs/platforms/dotnet/guides/winui/index.mdx | 2 -- docs/platforms/dotnet/guides/wpf/index.mdx | 1 - docs/platforms/dotnet/guides/xamarin/index.mdx | 1 - docs/platforms/dotnet/index.mdx | 1 - 13 files changed, 1 insertion(+), 20 deletions(-) diff --git a/docs/platforms/dotnet/guides/aspnet/index.mdx b/docs/platforms/dotnet/guides/aspnet/index.mdx index 37493121ef642..526d701cd0ba5 100644 --- a/docs/platforms/dotnet/guides/aspnet/index.mdx +++ b/docs/platforms/dotnet/guides/aspnet/index.mdx @@ -60,7 +60,6 @@ public class MvcApplication : HttpApplication options.SendDefaultPii = true; options.EnableLogs = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; diff --git a/docs/platforms/dotnet/guides/aspnetcore/index.mdx b/docs/platforms/dotnet/guides/aspnetcore/index.mdx index 953b9886c775c..32f2f1999e12a 100644 --- a/docs/platforms/dotnet/guides/aspnetcore/index.mdx +++ b/docs/platforms/dotnet/guides/aspnetcore/index.mdx @@ -46,7 +46,6 @@ builder.WebHost.UseSentry(options => { options.EnableLogs = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; @@ -62,7 +61,6 @@ public static IHostBuilder CreateHostBuilder(string[] args) => { options.EnableLogs = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; @@ -77,7 +75,6 @@ public static IWebHost BuildWebHost(string[] args) => { options.EnableLogs = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; @@ -135,7 +132,6 @@ Finally, any settings that can be configured via `appsettings.json` or environme options.EnableLogs = true; options.SendDefaultPii = true; // Adds request URL and headers, IP and name for users, etc. // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; @@ -153,7 +149,6 @@ Finally, any settings that can be configured via `appsettings.json` or environme options.EnableLogs <- true options.SendDefaultPii <- true // Adds request URL and headers, IP and name for users, etc. // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate <- 1.0 diff --git a/docs/platforms/dotnet/guides/aws-lambda/index.mdx b/docs/platforms/dotnet/guides/aws-lambda/index.mdx index 75fe826abb929..53bc49b9622a0 100644 --- a/docs/platforms/dotnet/guides/aws-lambda/index.mdx +++ b/docs/platforms/dotnet/guides/aws-lambda/index.mdx @@ -52,10 +52,9 @@ public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFu // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. - o.TracesSampleRate = 1.0; + options.TracesSampleRate = 1.0; // Required in Serverless environments options.FlushOnCompletedRequest = true; }) diff --git a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx index 4fc569dc4beeb..853480c21d36e 100644 --- a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx +++ b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx @@ -66,7 +66,6 @@ var host = new HostBuilder() { options.Dsn = "___PUBLIC_DSN___"; options.EnableLogs = true; - // Enables Tracing. // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. diff --git a/docs/platforms/dotnet/guides/blazor-server/index.mdx b/docs/platforms/dotnet/guides/blazor-server/index.mdx index cd8eb7ebb46a5..1881efee123bb 100644 --- a/docs/platforms/dotnet/guides/blazor-server/index.mdx +++ b/docs/platforms/dotnet/guides/blazor-server/index.mdx @@ -48,7 +48,6 @@ builder.WebHost.UseSentry(options => // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 0.1; @@ -105,7 +104,6 @@ builder.WebHost.UseSentry(options => options.Dsn = "___PUBLIC_DSN___"; options.UseOpenTelemetry(); // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 0.1; diff --git a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx index 8d8bd7a07fae9..84ed1551d5a36 100644 --- a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx +++ b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx @@ -51,7 +51,6 @@ builder.UseSentry(options => // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 0.1; diff --git a/docs/platforms/dotnet/guides/entityframework/index.mdx b/docs/platforms/dotnet/guides/entityframework/index.mdx index 8369587d92184..72e2f5bd90f87 100644 --- a/docs/platforms/dotnet/guides/entityframework/index.mdx +++ b/docs/platforms/dotnet/guides/entityframework/index.mdx @@ -66,7 +66,6 @@ public class MvcApplication : System.Web.HttpApplication // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; diff --git a/docs/platforms/dotnet/guides/maui/index.mdx b/docs/platforms/dotnet/guides/maui/index.mdx index df854b1f44fa2..248898e68fc60 100644 --- a/docs/platforms/dotnet/guides/maui/index.mdx +++ b/docs/platforms/dotnet/guides/maui/index.mdx @@ -71,7 +71,6 @@ public static MauiApp CreateMauiApp() // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; diff --git a/docs/platforms/dotnet/guides/winforms/index.mdx b/docs/platforms/dotnet/guides/winforms/index.mdx index 17ca0dc965318..242e74ec80c26 100644 --- a/docs/platforms/dotnet/guides/winforms/index.mdx +++ b/docs/platforms/dotnet/guides/winforms/index.mdx @@ -67,7 +67,6 @@ namespace WindowsFormsApp1 // Adds request URL and headers, IP and name for users, etc. SendDefaultPii = true, // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. TracesSampleRate = 1.0, diff --git a/docs/platforms/dotnet/guides/winui/index.mdx b/docs/platforms/dotnet/guides/winui/index.mdx index 8579b0c0c69cc..19f26f905c7ae 100644 --- a/docs/platforms/dotnet/guides/winui/index.mdx +++ b/docs/platforms/dotnet/guides/winui/index.mdx @@ -51,7 +51,6 @@ sealed partial class App : Application // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - // Enables Tracing. // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. @@ -103,7 +102,6 @@ sealed partial class App : Application // Adds request URL and headers, IP and name for users, etc. o.SendDefaultPii = true; - // Enables Tracing. // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. diff --git a/docs/platforms/dotnet/guides/wpf/index.mdx b/docs/platforms/dotnet/guides/wpf/index.mdx index cb603f1f49048..bc4201676321e 100644 --- a/docs/platforms/dotnet/guides/wpf/index.mdx +++ b/docs/platforms/dotnet/guides/wpf/index.mdx @@ -44,7 +44,6 @@ public partial class App : Application // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; diff --git a/docs/platforms/dotnet/guides/xamarin/index.mdx b/docs/platforms/dotnet/guides/xamarin/index.mdx index 602ffc7d54d58..aca3c95e28016 100644 --- a/docs/platforms/dotnet/guides/xamarin/index.mdx +++ b/docs/platforms/dotnet/guides/xamarin/index.mdx @@ -45,7 +45,6 @@ SentryXamarin.Init(options => // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0; diff --git a/docs/platforms/dotnet/index.mdx b/docs/platforms/dotnet/index.mdx index 17c92b143214e..95cc01fddc0aa 100644 --- a/docs/platforms/dotnet/index.mdx +++ b/docs/platforms/dotnet/index.mdx @@ -61,7 +61,6 @@ SentrySdk.Init(options => // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; // Enables Tracing. - // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0f; From c74a637701e7ad776d92523a25924ddaea0f3067 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 07:28:22 +0000 Subject: [PATCH 6/6] docs(dotnet): Address review feedback on quickstart guides - Use Dictionary initializers for metric attributes so snippets compile on .NET Framework (C# 7.3) - Drop metrics from the Xamarin guide and mark Metrics as not supported for Xamarin - Make profiling an optional .NET 8+ Alpha step in the .NET quickstart - Set the DSN in all ASP.NET Core setup tabs and remove duplicate appsettings options - Keep Session Replay masking defaults in the Android guide - Add Logs setup and example to the AWS Lambda guide --- .../platforms/dotnet/common/metrics/index.mdx | 2 + .../platforms/dotnet/guides/android/index.mdx | 8 ++-- docs/platforms/dotnet/guides/apple/index.mdx | 6 +-- docs/platforms/dotnet/guides/aspnet/index.mdx | 6 +-- .../dotnet/guides/aspnetcore/index.mdx | 18 ++++---- .../dotnet/guides/aws-lambda/index.mdx | 35 ++++++++++++-- .../guides/azure-functions-worker/index.mdx | 6 +-- .../dotnet/guides/blazor-server/index.mdx | 6 +-- .../guides/blazor-webassembly/index.mdx | 6 +-- .../dotnet/guides/entityframework/index.mdx | 6 +-- .../guides/google-cloud-functions/index.mdx | 6 +-- docs/platforms/dotnet/guides/maui/index.mdx | 6 +-- .../dotnet/guides/winforms/index.mdx | 6 +-- docs/platforms/dotnet/guides/winui/index.mdx | 6 +-- docs/platforms/dotnet/guides/wpf/index.mdx | 6 +-- .../platforms/dotnet/guides/xamarin/index.mdx | 17 +------ docs/platforms/dotnet/index.mdx | 46 ++++++++++++++----- 17 files changed, 112 insertions(+), 80 deletions(-) diff --git a/docs/platforms/dotnet/common/metrics/index.mdx b/docs/platforms/dotnet/common/metrics/index.mdx index 6363af6ef13e6..01a94054b9d7b 100644 --- a/docs/platforms/dotnet/common/metrics/index.mdx +++ b/docs/platforms/dotnet/common/metrics/index.mdx @@ -5,6 +5,8 @@ description: "Metrics allow you to send, view and query counters, gauges and mea sidebar_order: 3 sidebar_section: features new: true +notSupported: + - dotnet.xamarin --- diff --git a/docs/platforms/dotnet/guides/android/index.mdx b/docs/platforms/dotnet/guides/android/index.mdx index 25c46f3c4eed7..275826bcbcc2c 100644 --- a/docs/platforms/dotnet/guides/android/index.mdx +++ b/docs/platforms/dotnet/guides/android/index.mdx @@ -80,8 +80,6 @@ public class MainActivity : Activity // Session Replay is currently available via the ExperimentalOptions options.Native.ExperimentalOptions.SessionReplay.OnErrorSampleRate = 1.0; options.Native.ExperimentalOptions.SessionReplay.SessionSampleRate = 1.0; - options.Native.ExperimentalOptions.SessionReplay.MaskAllImages = false; - options.Native.ExperimentalOptions.SessionReplay.MaskAllText = false; options.SetBeforeSend(evt => { @@ -150,11 +148,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/apple/index.mdx b/docs/platforms/dotnet/guides/apple/index.mdx index c5e0cb7612e3c..cacafbc17d0c4 100644 --- a/docs/platforms/dotnet/guides/apple/index.mdx +++ b/docs/platforms/dotnet/guides/apple/index.mdx @@ -128,11 +128,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/aspnet/index.mdx b/docs/platforms/dotnet/guides/aspnet/index.mdx index 526d701cd0ba5..a49d3a19ad296 100644 --- a/docs/platforms/dotnet/guides/aspnet/index.mdx +++ b/docs/platforms/dotnet/guides/aspnet/index.mdx @@ -136,11 +136,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/aspnetcore/index.mdx b/docs/platforms/dotnet/guides/aspnetcore/index.mdx index 32f2f1999e12a..4b33240722ece 100644 --- a/docs/platforms/dotnet/guides/aspnetcore/index.mdx +++ b/docs/platforms/dotnet/guides/aspnetcore/index.mdx @@ -31,7 +31,7 @@ This guide also enables **Tracing**. The simplest way to initialize Sentry in ASP.NET Core is by using the `UseSentry` extension method from the `Sentry.AspNetCore` package in conjunction with the [framework configuration system](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-7.0). -When configuring the SDK via the frameworks configuration system, it's possible to add the SDK by simply calling `UseSentry` without providing any further information. The SDK provides this as extension methods to support ASP.NET Core `2.X`, `3.X`, and `5.X` and later: +Call `UseSentry` with your DSN and the options you want. The SDK provides this as extension methods to support ASP.NET Core `2.X`, `3.X`, and `5.X` and later. The snippet also turns on: @@ -44,6 +44,7 @@ Don't need a feature? Remove its options from the snippet. var builder = WebApplication.CreateBuilder(args); builder.WebHost.UseSentry(options => { + options.Dsn = "___PUBLIC_DSN___"; options.EnableLogs = true; // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. @@ -59,6 +60,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => { webBuilder.UseSentry(options => { + options.Dsn = "___PUBLIC_DSN___"; options.EnableLogs = true; // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. @@ -73,6 +75,7 @@ public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseSentry(options => { + options.Dsn = "___PUBLIC_DSN___"; options.EnableLogs = true; // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. @@ -100,13 +103,10 @@ An example of some of the options that can be configured via `appsettings.json`: "MinimumEventLevel": "Warning", "AttachStackTrace": true, "Debug": true, - "DiagnosticLevel": "Error", - "TracesSampleRate": 1.0, - "EnableLogs": true + "DiagnosticLevel": "Error" } } ``` -Setting `TracesSampleRate` to `1.0` captures 100% of spans. We recommend reducing this value in production. See Automatic Instrumentation for further information. ### Environment variables @@ -129,7 +129,6 @@ Finally, any settings that can be configured via `appsettings.json` or environme ```csharp .UseSentry(options => { - options.EnableLogs = true; options.SendDefaultPii = true; // Adds request URL and headers, IP and name for users, etc. // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. @@ -146,7 +145,6 @@ Finally, any settings that can be configured via `appsettings.json` or environme ```fsharp .UseSentry (fun options -> - options.EnableLogs <- true options.SendDefaultPii <- true // Adds request URL and headers, IP and name for users, etc. // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. @@ -317,11 +315,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/aws-lambda/index.mdx b/docs/platforms/dotnet/guides/aws-lambda/index.mdx index 53bc49b9622a0..088b899271e1f 100644 --- a/docs/platforms/dotnet/guides/aws-lambda/index.mdx +++ b/docs/platforms/dotnet/guides/aws-lambda/index.mdx @@ -21,7 +21,7 @@ You can combine this integration with a logging library like `log4net`, `NLog`, ## Configure -**Error Monitoring** starts working as soon as you initialize the SDK. **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Application Metrics](#send-application-metrics-). +**Error Monitoring** starts working as soon as you initialize the SDK. **Logs** sent through `Microsoft.Extensions.Logging` need `EnableLogs = true`, and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). This guide also enables **Tracing**. @@ -34,6 +34,7 @@ All `ASP.NET Core` configurations are valid here. But one configuration in parti The snippet also turns on: - Tracing: via `TracesSampleRate` +- Logs: via `EnableLogs` Don't need a feature? Remove its options from the snippet. @@ -47,6 +48,7 @@ public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFu .UseSentry(options => { options.Dsn = "___PUBLIC_DSN___"; + options.EnableLogs = true; // When configuring for the first time, to see what the SDK is doing: options.Debug = true; // Adds request URL and headers, IP and name for users, etc. @@ -65,6 +67,31 @@ public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFu Check out the [Sentry ASP.NET Core](/platforms/dotnet/guides/aspnetcore/) documentation for the complete set of options. +## Send Logs + +Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. + +See [Microsoft.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) for setup details. + +See Set Up Logs for all available logging methods and formatting options. + +```csharp +using Microsoft.Extensions.Logging; + +public sealed class OrderService +{ + private readonly ILogger _logger; + + public OrderService(ILogger logger) => _logger = logger; + + public void Process() + { + _logger.LogInformation("Order processed {OrderId}", "order-123"); + _logger.LogWarning("Rate limit reached for {Endpoint}", "/api/orders"); + } +} +``` + ## Send Application Metrics Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. @@ -73,11 +100,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx index f337e9f4dfb10..7fa4beee87e09 100644 --- a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx +++ b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx @@ -104,11 +104,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/blazor-server/index.mdx b/docs/platforms/dotnet/guides/blazor-server/index.mdx index 1881efee123bb..c05548bffc813 100644 --- a/docs/platforms/dotnet/guides/blazor-server/index.mdx +++ b/docs/platforms/dotnet/guides/blazor-server/index.mdx @@ -159,11 +159,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx index 84ed1551d5a36..bafbb652e24b1 100644 --- a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx +++ b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx @@ -95,11 +95,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/entityframework/index.mdx b/docs/platforms/dotnet/guides/entityframework/index.mdx index 72e2f5bd90f87..d08272d0a7fc5 100644 --- a/docs/platforms/dotnet/guides/entityframework/index.mdx +++ b/docs/platforms/dotnet/guides/entityframework/index.mdx @@ -112,11 +112,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/google-cloud-functions/index.mdx b/docs/platforms/dotnet/guides/google-cloud-functions/index.mdx index 582956bbfc65d..9b0f8af3ffd38 100644 --- a/docs/platforms/dotnet/guides/google-cloud-functions/index.mdx +++ b/docs/platforms/dotnet/guides/google-cloud-functions/index.mdx @@ -176,11 +176,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/maui/index.mdx b/docs/platforms/dotnet/guides/maui/index.mdx index 248898e68fc60..1688daecfafc0 100644 --- a/docs/platforms/dotnet/guides/maui/index.mdx +++ b/docs/platforms/dotnet/guides/maui/index.mdx @@ -161,11 +161,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/winforms/index.mdx b/docs/platforms/dotnet/guides/winforms/index.mdx index 242e74ec80c26..0c2e5915b5bd2 100644 --- a/docs/platforms/dotnet/guides/winforms/index.mdx +++ b/docs/platforms/dotnet/guides/winforms/index.mdx @@ -244,11 +244,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/winui/index.mdx b/docs/platforms/dotnet/guides/winui/index.mdx index 19f26f905c7ae..16f84ae9841b2 100644 --- a/docs/platforms/dotnet/guides/winui/index.mdx +++ b/docs/platforms/dotnet/guides/winui/index.mdx @@ -168,11 +168,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/wpf/index.mdx b/docs/platforms/dotnet/guides/wpf/index.mdx index bc4201676321e..f9a1444911649 100644 --- a/docs/platforms/dotnet/guides/wpf/index.mdx +++ b/docs/platforms/dotnet/guides/wpf/index.mdx @@ -84,11 +84,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup diff --git a/docs/platforms/dotnet/guides/xamarin/index.mdx b/docs/platforms/dotnet/guides/xamarin/index.mdx index aca3c95e28016..2e7800b29932c 100644 --- a/docs/platforms/dotnet/guides/xamarin/index.mdx +++ b/docs/platforms/dotnet/guides/xamarin/index.mdx @@ -19,7 +19,7 @@ The SDK is compatible with the following versions or higher: ## Configure -**Error Monitoring** starts working as soon as you initialize the SDK. **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Application Metrics](#send-application-metrics-). +**Error Monitoring** starts working as soon as you initialize the SDK. This guide also enables **Tracing**. @@ -82,21 +82,6 @@ Note that personally identifiable information (PII) might be included in the scr Disables the automatic Logging of internal Warnings that comes from Xamarin Forms. -## Send Application Metrics - -Metrics are enabled by default in Sentry .NET SDK 6.1.0 and later. Use `SentrySdk.Metrics` to send counters, gauges, and distributions from your app. - -See Set Up Metrics for all available metric types and configuration options. - -```csharp -SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); -SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); -SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); -``` - ## Verify Your Setup Let's test your setup and confirm that data reaches your Sentry project. diff --git a/docs/platforms/dotnet/index.mdx b/docs/platforms/dotnet/index.mdx index 95cc01fddc0aa..d6803feaf506d 100644 --- a/docs/platforms/dotnet/index.mdx +++ b/docs/platforms/dotnet/index.mdx @@ -26,22 +26,21 @@ If you're using a framework, such as ASP.NET Core or MAUI, please select the fra ## Install -Install the `Sentry` NuGet package to add the SDK. This guide also includes profiling setup for supported .NET targets, which requires `Sentry.Profiling`. +Install the `Sentry` NuGet package to add the SDK: ```shell {tabTitle:.NET Core CLI} dotnet add package Sentry -v {{@inject packages.version('sentry.dotnet') }} -dotnet add package Sentry.Profiling -v {{@inject packages.version('sentry.dotnet.profiling') }} ``` ```powershell {tabTitle:Package Manager} Install-Package Sentry -Version {{@inject packages.version('sentry.dotnet') }} -Install-Package Sentry.Profiling -Version {{@inject packages.version('sentry.dotnet.profiling') }} ``` + ## Configure **Error Monitoring** starts working as soon as you call `SentrySdk.Init()`. **Logs** sent through `SentrySdk.Logger` and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-). -This guide also enables **Tracing** and **Profiling**. +This guide also enables **Tracing**. **Profiling** is in Alpha and needs .NET 8 or later, so it's a separate step: see [Enable Profiling on .NET 8 and Later](#enable-profiling-on-net-8-and-later). To capture all errors, even the one during the startup of your application, you should initialize the Sentry .NET SDK as soon as possible. @@ -49,7 +48,6 @@ To capture all errors, even the one during the startup of your application, you The snippet also turns on: - Tracing: via `TracesSampleRate` -- Profiling: via `ProfilesSampleRate` and the profiling integration Don't need a feature? Remove its options from the snippet. @@ -64,13 +62,37 @@ SentrySdk.Init(options => // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. options.TracesSampleRate = 1.0f; - // Enables Profiling. - // Set to 1.0 to profile 100% of captured transactions. - options.ProfilesSampleRate = 1.0f; - options.AddProfilingIntegration(); }); ``` +### Enable Profiling on .NET 8 and Later + + + +Profiling for .NET is in Alpha and needs .NET 8 or later. On .NET Framework, `Sentry.Profiling` installs without a warning, but `AddProfilingIntegration()` doesn't compile. + + + +To profile your app, install the `Sentry.Profiling` package: + +```shell {tabTitle:.NET Core CLI} +dotnet add package Sentry.Profiling -v {{@inject packages.version('sentry.dotnet.profiling') }} +``` + +```powershell {tabTitle:Package Manager} +Install-Package Sentry.Profiling -Version {{@inject packages.version('sentry.dotnet.profiling') }} +``` + +Then add these options to `SentrySdk.Init()`: + +```csharp +// Enables Profiling for 100% of sampled transactions. +options.ProfilesSampleRate = 1.0f; +options.AddProfilingIntegration(); +``` + +See Set Up Profiling for supported platforms and options. + ## Send Logs Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option. @@ -90,11 +112,11 @@ See Set Up Metrics for all available ```csharp SentrySdk.Metrics.EmitCounter("button_click", 5, - [new KeyValuePair("browser", "Firefox")]); + new Dictionary { ["browser"] = "Firefox" }); SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("page", "/home")]); + new Dictionary { ["page"] = "/home" }); SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond, - [new KeyValuePair("endpoint", "/api/orders")]); + new Dictionary { ["endpoint"] = "/api/orders" }); ``` ## Verify Your Setup