Skip to content

Commit 9100f0e

Browse files
authored
Merge pull request #50290 from pharring/master
Add ShadowCopyFolder section to App Insights Snapshot Debugger
2 parents da43c55 + 9a39bfa commit 9100f0e

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

articles/application-insights/app-insights-snapshot-debugger.md

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ The following environments are supported:
161161

162162
### Configure snapshot collection for other .NET applications
163163

164-
1. If your application is not already instrumented with Application Insights, get started by [enabling Application Insights and setting the instrumentation key](app-insights-windows-desktop.md).
164+
1. If your application isn't already instrumented with Application Insights, get started by [enabling Application Insights and setting the instrumentation key](app-insights-windows-desktop.md).
165165

166166
2. Add the [Microsoft.ApplicationInsights.SnapshotCollector](http://www.nuget.org/packages/Microsoft.ApplicationInsights.SnapshotCollector) NuGet package in your app.
167167

@@ -231,7 +231,7 @@ The Snapshot Collector is implemented as an [Application Insights Telemetry Proc
231231
Each time your application calls [TrackException](app-insights-asp-net-exceptions.md#exceptions), the Snapshot Collector computes a Problem ID from the type of exception being thrown and the throwing method.
232232
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.
233233

234-
The Snapshot Collector also monitors exceptions as they are thrown by subscribing to the [AppDomain.CurrentDomain.FirstChanceException](https://docs.microsoft.com/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.
234+
The Snapshot Collector also monitors exceptions as they're thrown by subscribing to the [AppDomain.CurrentDomain.FirstChanceException](https://docs.microsoft.com/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.
235235
If there's a match, then 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 where it, along with the snapshot identifier, is reported to Application Insights.
236236

237237
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.
@@ -247,13 +247,14 @@ The main process continues to run and serve traffic to users with little interru
247247
## Current limitations
248248

249249
### Publish symbols
250-
The Snapshot Debugger requires symbol files on the production server to decode variables and to provide a debugging experience in Visual Studio. The 15.2 release of Visual Studio 2017 publishes symbols for release builds by default when it publishes to App Service. In prior versions, you need to add the following line to your publish profile `.pubxml` file so that symbols are published in release mode:
250+
The Snapshot Debugger requires symbol files on the production server to decode variables and to provide a debugging experience in Visual Studio.
251+
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 need to add the following line to your publish profile `.pubxml` file so that symbols are published in release mode:
251252

252253
```xml
253254
<ExcludeGeneratedDebugSymbol>False</ExcludeGeneratedDebugSymbol>
254255
```
255256

256-
For Azure Compute and other types, ensure that the symbol files are in the same folder of the main application .dll (typically, `wwwroot/bin`) or are available on the current path.
257+
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 are available on the current path.
257258

258259
### Optimized builds
259260
In some cases, local variables can't be viewed in release builds because of optimizations that are applied by the JIT compiler.
@@ -344,14 +345,14 @@ SnapshotUploader.exe Information: 0 : Deleted PDB scan marker : D:\local\Temp\Du
344345
DateTime=2018-03-09T01:47:19.4614027Z
345346
```
346347

347-
For applications that are _not_ hosted in App Service, the uploader logs are in the same folder as the minidumps: `%TEMP%\Dumps\<ikey>` (where `<ikey>` is your instrumentation key).
348+
For applications that _aren't_ hosted in App Service, the uploader logs are in the same folder as the minidumps: `%TEMP%\Dumps\<ikey>` (where `<ikey>` is your instrumentation key).
348349

349350
### Troubleshooting Cloud Services
350351
For roles in Cloud Services, the default temporary folder may be too small to hold the minidump files, leading to lost snapshots.
351352
The space needed depends on the total working set of your application and the number of concurrent snapshots.
352353
The working set of a 32-bit ASP.NET web role is typically between 200 MB and 500 MB.
353354
Allow for at least two concurrent snapshots.
354-
For example, if your application uses 1 GB of total working set, you should ensure that there is at least 2 GB of disk space to store snapshots.
355+
For example, if your application uses 1 GB of total working set, you should make sure that there is at least 2 GB of disk space to store snapshots.
355356
Follow these steps to configure your Cloud Service role with a dedicated local resource for snapshots.
356357

357358
1. Add a new local resource to your Cloud Service by editing the Cloud Service definition (.csdef) file. The following example defines a resource called `SnapshotStore` with a size of 5 GB.
@@ -398,6 +399,49 @@ Follow these steps to configure your Cloud Service role with a dedicated local r
398399
</TelemetryProcessors>
399400
```
400401

402+
### Overriding the Shadow Copy folder
403+
404+
When the Snapshot Collector starts up, it tries to find a folder on disk that is suitable for running the Snapshot Uploader process. The chosen folder is known as the Shadow Copy folder.
405+
406+
The Snapshot Collector checks a few well-known locations, making sure it has permissions to copy the Snapshot Uploader binaries. The following environment variables are used:
407+
- Fabric_Folder_App_Temp
408+
- LOCALAPPDATA
409+
- APPDATA
410+
- TEMP
411+
412+
If a suitable folder can't be found, Snapshot Collector reports an error saying _"Could not find a suitable shadow copy folder."_
413+
414+
If the copy fails, Snapshot Collector reports a `ShadowCopyFailed` error.
415+
416+
If the uploader can't be launched, Snapshot Collector reports an `UploaderCannotStartFromShadowCopy` error. The body of the message often contains `System.UnauthorizedAccessException`. This error usually occurs because the application is running under an account with reduced permissions. The account has permission to write to the shadow copy folder, but it doesn't have permission to execute code.
417+
418+
Since these errors usually happen during startup, they'll usually be followed by an `ExceptionDuringConnect` error saying _"Uploader failed to start."_
419+
420+
To work around these errors, you can specify the shadow copy folder manually via the `ShadowCopyFolder` configuration option. For example, using ApplicationInsights.config:
421+
422+
```xml
423+
<TelemetryProcessors>
424+
<Add Type="Microsoft.ApplicationInsights.SnapshotCollector.SnapshotCollectorTelemetryProcessor, Microsoft.ApplicationInsights.SnapshotCollector">
425+
<!-- Override the default shadow copy folder. -->
426+
<ShadowCopyFolder>D:\SnapshotUploader</ShadowCopyFolder>
427+
<!-- Other SnapshotCollector configuration options -->
428+
</Add>
429+
</TelemetryProcessors>
430+
```
431+
432+
Or, if you're using appsettings.json with a .NET Core application:
433+
434+
```json
435+
{
436+
"ApplicationInsights": {
437+
"InstrumentationKey": "<your instrumentation key>"
438+
},
439+
"SnapshotCollectorConfiguration": {
440+
"ShadowCopyFolder": "D:\\SnapshotUploader"
441+
}
442+
}
443+
```
444+
401445
### Use Application Insights search to find exceptions with snapshots
402446

403447
When a snapshot is created, the throwing exception is tagged with a snapshot ID. That snapshot ID is included as a custom property when the exception telemetry is reported to Application Insights. Using **Search** in Application Insights, you can find all telemetry with the `ai.snapshot.id` custom property.

0 commit comments

Comments
 (0)