Skip to content
2 changes: 2 additions & 0 deletions docs/platforms/dotnet/common/metrics/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

<AgentSetupCallout skill="sentry-dotnet-sdk" platformName=".NET" />
Expand Down
86 changes: 66 additions & 20 deletions docs/platforms/dotnet/guides/android/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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).
Comment thread
sentry-junior[bot] marked this conversation as resolved.

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 <PlatformLink to="/configuration/options/#TracesSampleRate">`TracesSampleRate`</PlatformLink>
- Session Replay: via <PlatformLink to="/configuration/native-options/#session-replay">`Native.ExperimentalOptions.SessionReplay`</PlatformLink>

Don't need a feature? Remove its options from the snippet.

```csharp
[Activity(Label = "@string/app_name", MainLauncher = true)]
Expand All @@ -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;
Expand All @@ -67,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 =>
{
Expand All @@ -95,7 +106,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 <PlatformLink to="/configuration/native-options/">Android Native Options</PlatformLink>.

### 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:

Expand All @@ -112,18 +123,53 @@ Use caution when enabling `LogCatIntegrationType.All`, as this may result in a l

</Alert>

### 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 <PlatformLink to="/logs/">Set Up Logs</PlatformLink> 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 <FeatureBadge type="new" />

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 <PlatformLink to="/metrics/">Set Up Metrics</PlatformLink> for all available metric types and configuration options.

```csharp
SentrySdk.Metrics.EmitCounter("button_click", 5,
new Dictionary<string, object> { ["browser"] = "Firefox" });
SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond,
new Dictionary<string, object> { ["page"] = "/home" });
SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond,
new Dictionary<string, object> { ["endpoint"] = "/api/orders" });
```

## Verify Your Setup

Let's test your setup and confirm that data reaches your Sentry project.

<PlatformContent includePath="getting-started-verify" />

### 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 <PlatformLink to="/configuration/native-options/">Android Native Options</PlatformLink>
85 changes: 72 additions & 13 deletions docs/platforms/dotnet/guides/apple/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 <PlatformLink to="/configuration/options/#TracesSampleRate">`TracesSampleRate`</PlatformLink>
- Profiling: via <PlatformLink to="/profiling/">`ProfilesSampleRate`</PlatformLink>. 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 <PlatformLink to="/configuration/native-options/#session-replay">`Native.ExperimentalOptions.SessionReplay`</PlatformLink>

Don't need a feature? Remove its options from the snippet.

```csharp
[Register("AppDelegate")]
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -73,6 +95,8 @@ public class AppDelegate : UIApplicationDelegate
Console.WriteLine(e);
};
});

return true;
}
}
```
Expand All @@ -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 <PlatformLink to="/configuration/native-options/">Apple Native Options</PlatformLink>.

## Verify
## Send Logs

Use `SentrySdk.Logger` to send logs at different levels. These logs are sent without an additional option.

See <PlatformLink to="/logs/">Set Up Logs</PlatformLink> 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 <FeatureBadge type="new" />

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 <PlatformLink to="/metrics/">Set Up Metrics</PlatformLink> for all available metric types and configuration options.

```csharp
SentrySdk.Metrics.EmitCounter("button_click", 5,
new Dictionary<string, object> { ["browser"] = "Firefox" });
SentrySdk.Metrics.EmitGauge("page_load", 15.0, MeasurementUnit.Duration.Millisecond,
new Dictionary<string, object> { ["page"] = "/home" });
SentrySdk.Metrics.EmitDistribution("api_latency", 187, MeasurementUnit.Duration.Millisecond,
new Dictionary<string, object> { ["endpoint"] = "/api/orders" });
```

## Verify Your Setup

Let's test your setup and confirm that data reaches your Sentry project.

<PlatformContent includePath="getting-started-verify" />

### 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 <PlatformLink to="/configuration/native-options/">Apple Native Options</PlatformLink>
Loading
Loading