diff --git a/src/docs/product/profiling/getting-started.mdx b/src/docs/product/profiling/getting-started.mdx index 14f69a630076b..596d2aca66991 100644 --- a/src/docs/product/profiling/getting-started.mdx +++ b/src/docs/product/profiling/getting-started.mdx @@ -23,7 +23,9 @@ Profiling depends on Sentry's performance monitoring product being enabled befor - [iOS](/platforms/apple/guides/ios/profiling/) - [React Native](/platforms/react-native/profiling/) [beta] - [Flutter](/platforms/flutter/profiling/) [experimental, iOS and macOS only] + - [.NET](/platforms/dotnet/profiling/) [experimental, iOS only] - Standalone and server apps + - [.NET](/platforms/dotnet/profiling/) [experimental] - [Node.js](/platforms/node/profiling/) - [Python](/platforms/python/profiling/) - [PHP](/platforms/php/profiling/) diff --git a/src/docs/product/profiling/index.mdx b/src/docs/product/profiling/index.mdx index a4419e61cd2e9..22c4adf0490d0 100644 --- a/src/docs/product/profiling/index.mdx +++ b/src/docs/product/profiling/index.mdx @@ -14,6 +14,7 @@ description: "Profiling offers a deeper level of visibility on top of traditiona - [iOS (Swift and Objective-C only)](/platforms/apple/profiling/) - [Flutter [experimental, iOS and macOS only]](/platforms/flutter/profiling/) - [Python](/platforms/python/profiling/) +- [.NET [experimental]](/platforms/dotnet/profiling/) - [Node.js](/platforms/node/profiling/) - [PHP (including Laravel and Symfony)](/platforms/php/profiling/) - [Browser JavaScript [beta]](/platforms/javascript/profiling/) diff --git a/src/platforms/dotnet/profiling/index.mdx b/src/platforms/dotnet/profiling/index.mdx new file mode 100644 index 0000000000000..6b092803ef293 --- /dev/null +++ b/src/platforms/dotnet/profiling/index.mdx @@ -0,0 +1,78 @@ +--- +title: Set Up Profiling +description: "Learn how to enable profiling in your app if it is not already set up." +sidebar_order: 5000 +--- + + + +With [profiling](/product/profiling/), Sentry allows you to collect and analyze performance profiles from real user devices in production to give you a complete picture of how your application performs in a variety of environments. + + + +Sentry profiling for .NET is available in _Alpha_ on .NET 6.0+ (tested on .NET 7.0 & .NET 8.0 as well) for: + +- Windows +- Linux +- macOS +- iOS +- Mac Catalyst + + + +## Enable Profiling + +To enable profiling, set the `ProfilesSampleRate`. +Additionally, for all platforms except iOS/Mac Catalyst, you need to add a dependency on the `Sentry.Profiling` NuGet package. + +```shell {tabTitle:.NET CLI} +dotnet add package Sentry.Profiling -v {{@inject packages.version('sentry.dotnet', '4.0.0-beta.8') }} +``` + +Profiling depends on Sentry’s performance monitoring product being enabled beforehand. To enable performance monitoring in the SDK, set the `TracesSampleRate` option to the desired value. + +```csharp {tabTitle:iOS/MacCatalyst} +SentrySdk.Init(options => +{ + // ... usual setup options omitted for clarity (see Getting Started) ... + + // Sample rate for your transactions, e.g. value 0.1 means we want to report 10% of transactions. + // We recommend adjusting this value in production. + options.TracesSampleRate = 1.0; + + // Sample rate for profiling, applied on top of othe TracesSampleRate, + // e.g. 0.2 means we want to profile 20 % of the captured transactions. + // We recommend adjusting this value in production. + options.ProfilesSampleRate = 1.0; +}); +``` + +```csharp {tabTitle:Windows/Linux/macOS} +SentrySdk.Init(options => +{ + // ... usual setup options omitted for clarity (see Getting Started) ... + + // Sample rate for your transactions, e.g. value 0.1 means we want to report 10% of transactions. + // Setting 1.0 means all transactions are profiled. + // We recommend adjusting this value in production. + options.TracesSampleRate = 1.0; + + // Sample rate for profiling, applied on top of othe TracesSampleRate, + // e.g. 0.2 means we want to profile 20 % of the captured transactions. + // We recommend adjusting this value in production. + options.ProfilesSampleRate = 1.0; + + // Requires NuGet package: Sentry.Profiling + // Note: by default, the profiler is initialized asynchronously, this can be tuned by passing an desired initialization timeout to the constructor. + options.AddIntegration(new ProfilingIntegration( + // During startup, wait up to 500ms to profile the app startup code. This could make launching the app a bit slower so comment it out if your prefer profiling to start asynchronously + TimeSpan.FromMilliseconds(500) + )); +}); +``` + +### + +Check out the performance setup documentation for more detailed information on how to configure sampling. +Setting the traces sample rate to 1.0 means all transactions will be captured. +Setting the profiles sample rate to 1.0 means all captured transactions will be profiled. diff --git a/src/platforms/dotnet/profiling/troubleshooting/index.mdx b/src/platforms/dotnet/profiling/troubleshooting/index.mdx new file mode 100644 index 0000000000000..688a978e4232a --- /dev/null +++ b/src/platforms/dotnet/profiling/troubleshooting/index.mdx @@ -0,0 +1,27 @@ +--- +title: Troubleshooting +description: "Learn how to troubleshoot your profiling setup." +sidebar_order: 5000 +--- + +### Profiles are not showing up + +If you don't see any profiling data in [sentry.io](https://sentry.io), you can try the following: + +- Ensure that performance monitoring is enabled. +- Ensure that the automatic instrumentation is sending performance data to Sentry by going to the **Performance** page in [sentry.io](https://sentry.io). +- If the automatic instrumentation is not sending performance data, try using custom instrumentation. +- Enable debug mode in the SDK and check the logs. +- If the transactions happen too soon after `Sentry.Init()`, they may not be captured yet. + This is because the `ProfilingIntegration()` from `Sentry.Profiling` NuGet package initializes asynchronously by default. + If you'd like to initialize it synchronously, set the desired timeout constructor argument, e.g. `new ProfilingIntegration(TimeSpan.FromMilliseconds(500))` to wait up to 500 ms for the profiler to start up. + Note: this doesn't apply to iOS and Mac Catalyst which use native profiling and are initialized synchronously. +- Maybe you're trying to capture profiles on a platform that is currently **not** supported, notably: + - .NET Framework; we only support .NET 6.0, .NET 7.0 and .NET 8.0 + - Native AOT - this is only supported for iOS and Mac Catalyst (alongside the standard Mono AOT) + - Android - currently not supported at all + +### `Unknown` frames + +Some frames will show up as `unknown` in the UI. This is because the SDK does not have information about the stack frame. +Usually, these are anonymous helper JIT-generated methods and present among `System` stack frames. diff --git a/src/wizard/dotnet/profiling-onboarding/dotnet/0.alert.md b/src/wizard/dotnet/profiling-onboarding/dotnet/0.alert.md new file mode 100644 index 0000000000000..79e6ab3e7af2a --- /dev/null +++ b/src/wizard/dotnet/profiling-onboarding/dotnet/0.alert.md @@ -0,0 +1,11 @@ +--- +name: .NET +doc_link: https://docs.sentry.io/platforms/dotnet/profiling/ +support_level: alpha +type: language +--- + +
+Profiling in .NET is currently available in alpha for .NET 6.0+ on Windows, Linux, macOS, iOS and Mac Catalyst. +There may be some bugs. We recognize the irony. +
diff --git a/src/wizard/dotnet/profiling-onboarding/dotnet/1.install.md b/src/wizard/dotnet/profiling-onboarding/dotnet/1.install.md new file mode 100644 index 0000000000000..24262a666d7f7 --- /dev/null +++ b/src/wizard/dotnet/profiling-onboarding/dotnet/1.install.md @@ -0,0 +1,11 @@ +--- +name: .NET +doc_link: https://docs.sentry.io/platforms/dotnet/profiling/ +support_level: alpha +type: language +--- + +#### Install + +For the Profiling integration to work, you must use the `Sentry` and `Sentry.Profiling` NuGet packages (minimum version v4.0.0) and Sentry. +Learn more about installation methods in our [full documentation](https://docs.sentry.io/platforms/dotnet/#install). diff --git a/src/wizard/dotnet/profiling-onboarding/dotnet/2.configure-performance.md b/src/wizard/dotnet/profiling-onboarding/dotnet/2.configure-performance.md new file mode 100644 index 0000000000000..623d107dc3fbc --- /dev/null +++ b/src/wizard/dotnet/profiling-onboarding/dotnet/2.configure-performance.md @@ -0,0 +1,23 @@ +--- +name: .NET +doc_link: https://docs.sentry.io/platforms/dotnet/profiling/ +support_level: alpha +type: language +--- + +#### Configure Performance + +Sentry’s performance monitoring product has to be enabled in order for Profiling to work. To enable performance monitoring in the SDK: + +```csharp +SentrySdk.Init(options => +{ + // A Sentry Data Source Name (DSN) is required. + // See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ + // You can set it in the SENTRY_DSN environment variable, or you can set it in code here. + options.Dsn = "___PUBLIC_DSN___"; + + // We recommend adjusting this value in production: + options.TracesSampleRate = 1.0; +}); +``` diff --git a/src/wizard/dotnet/profiling-onboarding/dotnet/3.configure-profiling.md b/src/wizard/dotnet/profiling-onboarding/dotnet/3.configure-profiling.md new file mode 100644 index 0000000000000..8b3e4addca4ce --- /dev/null +++ b/src/wizard/dotnet/profiling-onboarding/dotnet/3.configure-profiling.md @@ -0,0 +1,32 @@ +--- +name: .NET +doc_link: https://docs.sentry.io/platforms/dotnet/profiling/ +support_level: alpha +type: language +--- + +#### Configure Profiling + +Add the `ProfilesSampleRate` option to your SDK config. + +```csharp +SentrySdk.Init(options => +{ + // A Sentry Data Source Name (DSN) is required. + // See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ + // You can set it in the SENTRY_DSN environment variable, or you can set it in code here. + options.Dsn = "___PUBLIC_DSN___"; + + // We recommend adjusting this value in production: + options.TracesSampleRate = 1.0; + + // The sampling rate for profiling is relative to TracesSampleRate. + // Setting to 1.0 will profile 100% of sampled transactions. + // We recommend adjusting this value in production: + options.ProfilesSampleRate = 1.0; + + // Windows, Linux and macOS profiling requires NuGet package: Sentry.Profiling + // Note: by default, the profiler is initialized asynchronously, this can be tuned by passing an desired initialization timeout to the constructor. + options.AddIntegration(new ProfilingIntegration()); +}); +```