You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Debug exceptions in .NET applications using Snapshot Debugger
14
14
15
-
When an exception occurs, you can automatically collect a debug snapshot from your live web application. The debug snapshot shows the state of source code and variables at the moment the exception was thrown.
15
+
With Snapshot Debugger, you can automatically collect a debug snapshot when an exception occurs in your live .NET application. The debug snapshot shows the state of source code and variables at the moment the exception was thrown.
16
16
17
17
The Snapshot Debugger in [Application Insights](../app/app-insights-overview.md):
18
18
19
19
- Monitors system-generated logs from your web app.
20
20
- Collects snapshots on your top-throwing exceptions.
21
21
- Provides information you need to diagnose issues in production.
22
22
23
-
To use the Snapshot Debugger, you:
23
+
## How Snapshot Debugger works
24
24
25
-
- Include the [Snapshot Collector NuGet package](https://www.nuget.org/packages/Microsoft.ApplicationInsights.SnapshotCollector) in your application.
26
-
- Configure collection parameters in [`ApplicationInsights.config`](../app/configuration-with-applicationinsights-config.md).
27
-
28
-
## How snapshots work
29
-
30
-
The Snapshot Debugger is implemented as an [Application Insights telemetry processor](../app/configuration-with-applicationinsights-config.md#telemetry-processors-aspnet). When your application runs, the Snapshot Debugger telemetry processor is added to your application's system-generated logs pipeline.
25
+
The Snapshot Debugger is implemented as an [Application Insights telemetry processor](../app/configuration-with-applicationinsights-config.md#telemetry-processors-aspnet). When your application runs, the Snapshot Debugger telemetry processor is added to your application's system-generated logs pipeline. The Snapshot Debugger process is as follows:
31
26
32
-
Each time your application calls [TrackException](../app/asp-net-exceptions.md#exceptions), the Snapshot Debugger computes a problem ID from the type of exception being thrown and the throwing method.
33
-
Each time your application calls `TrackException`, a counter is incremented for the appropriate problem ID. When the counter reaches the `ThresholdForSnapshotting` value, the problem ID is added to a collection plan.
34
-
35
-
The Snapshot Debugger also monitors exceptions as they're thrown by subscribing to the [AppDomain.CurrentDomain.FirstChanceException](/dotnet/api/system.appdomain.firstchanceexception) event. When that event fires, the problem ID of the exception is computed and compared against the problem IDs in the collection plan.
36
-
37
-
If there's a match, a snapshot of the running process is created. The snapshot is assigned a unique identifier and the exception is stamped with that identifier. After the `FirstChanceException` handler returns, the thrown exception is processed as normal. Eventually, the exception reaches the `TrackException` method again. It's reported to Application Insights, along with the snapshot identifier.
27
+
1. Each time your application calls [`TrackException`](../app/asp-net-exceptions.md#exceptions):
28
+
1. The Snapshot Debugger computes a problem ID from the type of exception being thrown and the throwing method.
29
+
1. A counter is incremented for the appropriate problem ID.
30
+
1. When the counter reaches the `ThresholdForSnapshotting` value, the problem ID is added to a collection plan.
31
+
1. The Snapshot Debugger also monitors exceptions as they're thrown by subscribing to the [`AppDomain.CurrentDomain.FirstChanceException`](/dotnet/api/system.appdomain.firstchanceexception) event.
32
+
1. When this event fires, the problem ID of the exception is computed and compared against the problem IDs in the collection plan.
33
+
1. If there's a match between problem IDs, a snapshot of the running process is created.
34
+
1. The snapshot is assigned a unique identifier and the exception is stamped with that identifier.
35
+
1. After the `FirstChanceException` handler returns, the thrown exception is processed as normal.
36
+
1. Eventually, the exception reaches the `TrackException` method again. It's reported to Application Insights, along with the snapshot identifier.
38
37
39
38
The main process continues to run and serve traffic to users with little interruption. Meanwhile, the snapshot is handed off to the Snapshot Uploader process. The Snapshot Uploader creates a minidump and uploads it to Application Insights along with any relevant symbol (*.pdb*) files.
40
39
41
-
Snapshot creation tips:
42
-
* A process snapshot is a suspended clone of the running process.
43
-
* Creating the snapshot takes about 10 milliseconds to 20 milliseconds.
44
-
* The default value for `ThresholdForSnapshotting` is 1. This value is also the minimum. Your app has to trigger the same exception *twice* before a snapshot is created.
45
-
* Set `IsEnabledInDeveloperMode` to `true` if you want to generate snapshots while you debug in Visual Studio.
46
-
* The snapshot creation rate is limited by the `SnapshotsPerTenMinutesLimit` setting. By default, the limit is one snapshot every 10 minutes.
47
-
* No more than 50 snapshots per day can be uploaded.
40
+
> [!TIP]
41
+
> Snapshot creation tips:
42
+
> - A process snapshot is a suspended clone of the running process.
43
+
> - Creating the snapshot takes about 10 milliseconds to 20 milliseconds.
44
+
> - The default value for `ThresholdForSnapshotting` is 1. This value is also the minimum. Your app has to trigger the same exception *twice* before a snapshot is created.
45
+
> - Set `IsEnabledInDeveloperMode` to `true` if you want to generate snapshots while you debug in Visual Studio.
46
+
> - The snapshot creation rate is limited by the `SnapshotsPerTenMinutesLimit` setting. By default, the limit is one snapshot every 10 minutes.
47
+
> - No more than 50 snapshots per day can be uploaded.
48
48
49
49
## Supported applications and environments
50
50
@@ -73,9 +73,16 @@ The following environments are supported:
73
73
74
74
If you enabled the Snapshot Debugger but you aren't seeing snapshots, see the [Troubleshooting guide](snapshot-debugger-troubleshoot.md).
75
75
76
-
## Required permissions
76
+
## Requirements
77
77
78
-
Access to snapshots is protected by Azure role-based access control. To inspect a snapshot, you must first be added to the [Application Insights Snapshot Debugger](../../role-based-access-control/role-assignments-portal.md) role. Subscription owners can assign this role to individual users or groups for the target **Application Insights Snapshot**.
78
+
### Packages and configurations
79
+
80
+
- Include the [Snapshot Collector NuGet package](https://www.nuget.org/packages/Microsoft.ApplicationInsights.SnapshotCollector) in your application.
81
+
- Configure collection parameters in [`ApplicationInsights.config`](../app/configuration-with-applicationinsights-config.md).
82
+
83
+
### Permissions
84
+
85
+
Since access to snapshots is protected by Azure role-based access control, you must be added to the [Application Insights Snapshot Debugger](../../role-based-access-control/role-assignments-portal.md) role. Subscription owners can assign this role to individual users or groups for the target **Application Insights Snapshot**.
79
86
80
87
For more information, see [Assign Azure roles by using the Azure portal](../../role-based-access-control/role-assignments-portal.md).
81
88
@@ -92,30 +99,36 @@ Debug snapshots are stored for 15 days. The default data retention policy is set
92
99
93
100
### Publish symbols
94
101
95
-
The Snapshot Debugger requires symbol files on the production server to decode variables and to provide a debugging experience in Visual Studio.
102
+
The Snapshot Debugger requires symbol files on the production server to:
103
+
- Decode variables
104
+
- Provide a debugging experience in Visual Studio
105
+
106
+
By default, Visual Studio 2017 version 15.2 (or above) publishes symbols for release builds when it publishes to App Service.
96
107
97
-
Version 15.2 (or above) of Visual Studio 2017 publishes symbols for release builds by default when it publishes to App Service. In prior versions, you must add the following line to your publish profile `.pubxml` file so that symbols are published in release mode:
108
+
In prior versions, you must add the following line to your publish profile `.pubxml` file so that symbols are published in release mode:
For Azure Compute and other types, make sure that the symbol files are in the same folder of the main application .dll (typically, `wwwroot/bin`). Or they must be available on the current path.
114
+
For Azure Compute and other types, make sure that the symbol files are either:
115
+
- In the same folder of the main application `.dll` (typically, `wwwroot/bin`), or
116
+
- Available on the current path.
104
117
105
118
For more information on the different symbol options that are available, see the [Visual Studio documentation](/visualstudio/ide/reference/advanced-build-settings-dialog-box-csharp). For best results, we recommend that you use *Full*, *Portable*, or *Embedded*.
106
119
107
120
### Optimized builds
108
121
109
-
In some cases, local variables can't be viewed in release builds because of optimizations that are applied by the JIT compiler.
122
+
In some cases, local variables can't be viewed in release builds because of optimizations applied by the JIT compiler.
110
123
111
-
However, in App Service, the Snapshot Collector can deoptimize throwing methods that are part of its collection plan.
124
+
However, in App Service, the Snapshot Debugger can deoptimize throwing methods that are part of its collection plan.
112
125
113
126
> [!TIP]
114
127
> Install the Application Insights Site extension in your instance of App Service to get deoptimization support.
115
128
116
129
## Release notes for Microsoft.ApplicationInsights.SnapshotCollector
117
130
118
-
This article contains the release notes for the `Microsoft.ApplicationInsights.SnapshotCollector` NuGet package for .NET applications, which is used by the Application Insights Snapshot Debugger.
131
+
This sectikon contains the release notes for the `Microsoft.ApplicationInsights.SnapshotCollector` NuGet package for .NET applications, which is used by the Application Insights Snapshot Debugger.
119
132
120
133
[Learn](./snapshot-debugger.md) more about the Application Insights Snapshot Debugger for .NET applications.
0 commit comments