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
Copy file name to clipboardExpand all lines: support/azure/azure-monitor/app-insights/telemetry/asp-net-troubleshoot-no-data.md
+54-15Lines changed: 54 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,14 +32,14 @@ Example scenarios:
32
32
* Check whether you're experiencing data loss at the [telemetry channel](/azure/azure-monitor/app/telemetry-channels#does-the-application-insights-channel-guarantee-telemetry-delivery-if-not-what-are-the-scenarios-in-which-telemetry-can-be-lost).
33
33
* Check for any known issues in the telemetry channel of the [GitHub repo](https://github.com/Microsoft/ApplicationInsights-dotnet/issues).
34
34
35
-
>[!Note]
36
-
>If data is missing, it's possible that the data is being rejected by the back end. This situation can occur for various reasons, including the following causes:
35
+
>[!NOTE]
36
+
>If data is missing, it's possible that the data is being rejected by the back end. This situation can occur for various reasons, including the following causes:
37
37
>
38
-
>* Required fields are missing.
39
-
>* One or more fields exceed size limits.
40
-
>* SDKs are failing silently instead of throwing exceptions.
38
+
>* Required fields are missing.
39
+
>* One or more fields exceed size limits.
40
+
>* SDKs are failing silently instead of throwing exceptions.
41
41
>
42
-
>You can use a tool like [Fiddler](https://www.telerik.com/fiddler/fiddler-classic), or any other tool that will inspect HTTP traffic, to confirm successful telemetry uploads. The back end will return a "200 OK" HTTP status code to indicate a successful upload. Or you can use the [SDK logs](#troubleshoot-logs) to see if the back end is rejecting data.
42
+
>You can use a tool like [Fiddler](https://www.telerik.com/fiddler/fiddler-classic), or any other tool that will inspect HTTP traffic, to confirm successful telemetry uploads. The back end will return a "200 OK" HTTP status code to indicate a successful upload. Or you can use the [SDK logs](#troubleshoot-logs) to see if the back end is rejecting data.
43
43
44
44
### I'm experiencing data loss in a console app or on a web app when the app is about to stop
45
45
@@ -224,18 +224,24 @@ Example scenario:
224
224
* Run your application in debug mode in Visual Studio (F5). Use the application to generate some telemetry. Check that you can see events logged in the Visual Studio output window.
225
225
226
226
:::image type="content" source="./media/asp-net-troubleshoot-no-data/output-window.png" alt-text="Screenshot that shows an application running in debug mode in Visual Studio.":::
227
+
227
228
* In the Application Insights portal, select **Overview** > [Search](/azure/azure-monitor/app/diagnostic-search). Data usually appears here first.
229
+
228
230
* Select **Refresh**. The pane refreshes itself periodically, but you can also do it manually. The refresh interval is longer for larger time ranges.
231
+
229
232
* Verify that the [connection strings](/azure/azure-monitor/app/sdk-connection-string) match. On the main pane for your app in the Application Insights portal, in the **Essentials** dropdown list, look at **Connection string**. Then, in your project in Visual Studio, open *ApplicationInsights.config* and find the `<ConnectionString>` element. Check whether the two strings are equal. If the strings don't match, take one of the following actions:
230
233
231
-
| Environment | Action |
232
-
| ----------- | ------ |
233
-
| [Azure portal](https://portal.azure.com) | Search for and select **Application Insights** and then look for the app resource with the right string. |
234
-
| Visual Studio | In Visual Studio Solution Explorer, right-click the project and select **Application Insights** > **Configure**. Reset the app to send telemetry to the correct resource. |
234
+
| Environment | Action |
235
+
| ----------- | ------ |
236
+
| [Azure portal](https://portal.azure.com) | Search for and select **Application Insights** and then look for the app resource with the right string. |
237
+
| Visual Studio | In Visual Studio Solution Explorer, right-click the project and select **Application Insights** > **Configure**. Reset the app to send telemetry to the correct resource. |
235
238
236
239
If you can't find the matching strings, check to make sure that you're using the same sign-in credentials in Visual Studio that you're using to sign in to the portal.
240
+
237
241
* In the [Azure portal](https://portal.azure.com), search for and select **Service Health**. If the map has some alert indications, wait until they've returned to health. Then close and reopen your Application Insights application pane.
242
+
238
243
* Did you write any code for the [server-side SDK](/azure/azure-monitor/app/api-custom-events-metrics) that might change the [connection string](/azure/azure-monitor/app/sdk-connection-string) in `TelemetryClient` instances or in `TelemetryContext`? Or did you write a [filter or sampling configuration](/azure/azure-monitor/app/api-filtering-sampling) that might be filtering out too much?
244
+
239
245
* If you edited *ApplicationInsights.config*, carefully check the configuration of [\<TelemetryInitializers> and \<TelemetryProcessors> elements](/azure/azure-monitor/app/api-filtering-sampling). An incorrectly named type or parameter can cause the SDK to send no data.
240
246
241
247
## No data on page views, browsers, and usage
@@ -271,15 +277,15 @@ Performance data like CPU and the I/O rate is available for the following enviro
271
277
272
278
## Performance impact when Application Insights is enabled
273
279
274
-
Enabling Application Insights SDK in your application may occasionally lead to performance issues, such as high CPU usage, memory leaks, thread leaks, or TCP port exhaustion. These issues commonly originate from the application leaking `Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration` objects. Each leaked instance creates two additional threads, which leading to a continual increase in the process's thread count over time. If you observe a growing number of threads, it's crucial to check for leaks of [TelemetryConfiguration](/dotnet/api/microsoft.applicationinsights.extensibility.telemetryconfiguration?view=azure-dotnet&preserve-view=true) objects.
280
+
Enabling Application Insights SDK in your application may occasionally lead to performance issues, such as high CPU usage, memory leaks, thread leaks, or TCP port exhaustion. These issues commonly originate from the application leaking `Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration` objects. Each leaked instance creates two additional threads, which leading to a continual increase in the process's thread count over time. If you observe a growing number of threads, it's crucial to check for leaks of [TelemetryConfiguration](/dotnet/api/microsoft.applicationinsights.extensibility.telemetryconfiguration?view=azure-dotnet&preserve-view=true) objects.
275
281
276
282
### Common causes of TelemetryConfiguration leaks
277
283
278
284
There are two primary causes of leaking `TelemetryConfiguration` objects:
279
285
280
-
- **Explicit creation in code**: If you create `TelemetryConfiguration` objects within your code, ensure that they are not inadvertently created per web request. Instead, use a shared global instance. For .NET Framework applications, access the global instance with `TelemetryConfiguration.Active`. For .NET Core applications, use `TelemetryConfiguration.CreateDefault()` to obtain a default configuration.
286
+
* **Explicit creation in code**: If you create `TelemetryConfiguration` objects within your code, ensure that they are not inadvertently created per web request. Instead, use a shared global instance. For .NET Framework applications, access the global instance with `TelemetryConfiguration.Active`. For .NET Core applications, use `TelemetryConfiguration.CreateDefault()` to obtain a default configuration.
281
287
282
-
- **Improper service provider usage**: In .NET Core applications, avoid calling `services.BuildServiceProvider()` within `ConfigureServices`. BuildServiceProvider method creates a new service provider that initializes and reads the configuration, resulting in a new `TelemetryConfiguration` object each time. Such a pattern can lead to leaks and is discouraged, as noted in the [Visual Studio warning](/aspnet/core/diagnostics/asp0000?view=aspnetcore-8.0&preserve-view=true) against this coding practice.
288
+
* **Improper service provider usage**: In .NET Core applications, avoid calling `services.BuildServiceProvider()` within `ConfigureServices`. BuildServiceProvider method creates a new service provider that initializes and reads the configuration, resulting in a new `TelemetryConfiguration` object each time. Such a pattern can lead to leaks and is discouraged, as noted in the [Visual Studio warning](/aspnet/core/diagnostics/asp0000?view=aspnetcore-8.0&preserve-view=true) against this coding practice.
283
289
284
290
## I used to see data, but it's stopped
285
291
@@ -311,7 +317,7 @@ Did you build for .NET [Long Term Support (LTS)](https://dotnet.microsoft.com/pl
311
317
312
318
Follow these instructions to capture troubleshooting logs for your framework.
313
319
314
-
### .NET Framework
320
+
### [.NET Framework](#tab/framework)
315
321
316
322
> [!NOTE]
317
323
> Starting in version 2.14, the [Microsoft.AspNet.ApplicationInsights.HostingStartup](https://www.nuget.org/packages/Microsoft.AspNet.ApplicationInsights.HostingStartup) package is no longer necessary. SDK logs are now collected with the [Microsoft.ApplicationInsights](https://www.nuget.org/packages/Microsoft.ApplicationInsights/) package. No other package is required.
@@ -334,7 +340,7 @@ Follow these instructions to capture troubleshooting logs for your framework.
334
340
335
341
1. Revert these changes when you're finished.
336
342
337
-
### .NET Core
343
+
### [.NET Core](#tab/core)
338
344
339
345
1. Install the [Application Insights SDK NuGet package for ASP.NET Core](https://nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) package from NuGet. The version you install must match the current installed version of `Microsoft.ApplicationInsights`.
340
346
@@ -357,6 +363,8 @@ Follow these instructions to capture troubleshooting logs for your framework.
357
363
358
364
1. Revert these changes when you're finished.
359
365
366
+
---
367
+
360
368
## Collect logs with PerfView
361
369
362
370
[PerfView](https://github.com/Microsoft/perfview) is a free tool that helps isolate CPU, memory, and other issues.
@@ -388,10 +396,41 @@ After you install `dotnet-trace`, run the following [dotnet-trace collect](/dotn
#### What causes delayed telemetry, an overloaded network, and inefficient transmission?
402
+
403
+
System.Diagnostics.Tracing has an [Autoflush feature](/dotnet/api/system.diagnostics.trace.autoflush). This feature causes SDK to flush with every telemetry item, which is undesirable, and can cause logging adapter issues like delayed telemetry, an overloaded network, and inefficient transmission.
404
+
405
+
#### Why is there no Application Insights option on the project context menu?
406
+
407
+
* Make sure that Developer Analytics Tools is installed on the development machine. In Visual Studio, go to **Tools** > **Extensions and Updates**, and look for **Developer Analytics Tools**. If it isn't on the **Installed** tab, open the **Online** tab and install it.
408
+
* This project type might be one that Developer Analytics Tools doesn't support. Use [manual installation](/azure/azure-monitor/app/dotnet#add-application-insights-manually-no-visual-studio).
409
+
410
+
#### Why is there no log adapter option in the configuration tool?
411
+
412
+
* Install the logging framework first.
413
+
* If you're using System.Diagnostics.Trace, make sure that you [configured it in *web.config*](/dotnet/api/system.diagnostics.eventlogtracelistener).
414
+
* Make sure that you have the latest version of Application Insights. In Visual Studio, go to **Tools** > **Extensions and Updates** and open the **Updates** tab. If **Developer Analytics Tools** is there, select it to update it.
415
+
416
+
#### Why do I get the "Instrumentation key cannot be empty" error message?
417
+
418
+
You probably installed the logging adapter NuGet package without installing Application Insights. In Solution Explorer, right-click *ApplicationInsights.config*, and select **Update Application Insights**. You're prompted to sign in to Azure and create an Application Insights resource or reuse an existing one. It should fix the problem.
419
+
420
+
#### Why can I see traces but not other events in diagnostic search?
421
+
422
+
It can take a while for all the events and requests to get through the pipeline.
423
+
424
+
#### Why don't I see some log entries that I expected?
425
+
426
+
Perhaps your application sends voluminous amounts of data and you're using the Application Insights SDK for ASP.NET version 2.0.0-beta3 or later. In this case, the adaptive sampling feature might operate and send only a portion of your telemetry. Learn more about [sampling](/azure/azure-monitor/app/sampling).
427
+
391
428
## Remove Application Insights
392
429
393
430
To remove Application Insights in Visual Studio, follow the steps provided in [Remove Application Insights in Visual Studio](/azure/azure-monitor/app/remove-application-insights).
394
431
432
+
There's a known issue in Visual Studio 2019: storing the instrumentation key or connection string in a user secret is broken for .NET Framework-based apps. The key ultimately has to be hardcoded into the *Applicationinsights.config* file to work around this bug. This article is designed to avoid this issue entirely, by not using user secrets.
433
+
395
434
## It still isn't working
396
435
397
436
See the [Microsoft Q&A page for Application Insights](/answers/tags/20/azure-monitor).
0 commit comments