Skip to content

Commit 20bcc16

Browse files
authored
Merge pull request #207880 from paulth1/tracing-web-app-availability-javascript
edit pass: Tracing web app availability javascript
2 parents 780ef08 + 023b2b1 commit 20bcc16

File tree

4 files changed

+254
-240
lines changed

4 files changed

+254
-240
lines changed

articles/azure-monitor/app/asp-net-core.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,16 @@ The preceding steps are enough to help you start collecting server-side telemetr
173173

174174
1. In `_ViewImports.cshtml`, add injection:
175175

176-
```cshtml
177-
@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
178-
```
176+
```cshtml
177+
@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
178+
```
179179

180180
2. In `_Layout.cshtml`, insert `HtmlHelper` at the end of the `<head>` section but before any other script. If you want to report any custom JavaScript telemetry from the page, inject it after this snippet:
181181

182-
```cshtml
183-
@Html.Raw(JavaScriptSnippet.FullScript)
184-
</head>
185-
```
182+
```cshtml
183+
@Html.Raw(JavaScriptSnippet.FullScript)
184+
</head>
185+
```
186186

187187
As an alternative to using the `FullScript`, the `ScriptBody` is available starting in Application Insights SDK for ASP.NET Core version 2.14. Use `ScriptBody` if you need to control the `<script>` tag to set a Content Security Policy:
188188

@@ -197,7 +197,7 @@ The `.cshtml` file names referenced earlier are from a default MVC application t
197197
If your project doesn't include `_Layout.cshtml`, you can still add [client-side monitoring](./website-monitoring.md) by adding the JavaScript snippet to an equivalent file that controls the `<head>` of all pages within your app. Alternatively, you can add the snippet to multiple pages, but we don't recommend it.
198198

199199
> [!NOTE]
200-
> JavaScript injection provides a default configuration experience. If you require [configuration](./javascript.md#configuration) beyond setting the connection string, you are required to remove auto-injection as described above and manually add the [JavaScript SDK](./javascript.md#adding-the-javascript-sdk).
200+
> JavaScript injection provides a default configuration experience. If you require [configuration](./javascript.md#configuration) beyond setting the connection string, you are required to remove auto-injection as described above and manually add the [JavaScript SDK](./javascript.md#add-the-javascript-sdk).
201201
202202
## Configure the Application Insights SDK
203203

@@ -326,13 +326,13 @@ Application Insights automatically collects telemetry about specific workloads w
326326

327327
By default, the following automatic-collection modules are enabled. These modules are responsible for automatically collecting telemetry. You can disable or configure them to alter their default behavior.
328328

329-
* `RequestTrackingTelemetryModule` - Collects RequestTelemetry from incoming web requests
330-
* `DependencyTrackingTelemetryModule` - Collects [DependencyTelemetry](./asp-net-dependencies.md) from outgoing http calls and sql calls
331-
* `PerformanceCollectorModule` - Collects Windows PerformanceCounters
332-
* `QuickPulseTelemetryModule` - Collects telemetry for showing in Live Metrics portal
333-
* `AppServicesHeartbeatTelemetryModule` - Collects heart beats (which are sent as custom metrics), about Azure App Service environment where application is hosted
334-
* `AzureInstanceMetadataTelemetryModule` - Collects heart beats (which are sent as custom metrics), about Azure VM environment where application is hosted
335-
* `EventCounterCollectionModule` - Collects [EventCounters](eventcounters.md); this module is a new feature and is available in SDK version 2.8.0 and later
329+
* `RequestTrackingTelemetryModule`: Collects RequestTelemetry from incoming web requests
330+
* `DependencyTrackingTelemetryModule`: Collects [DependencyTelemetry](./asp-net-dependencies.md) from outgoing http calls and sql calls
331+
* `PerformanceCollectorModule`: Collects Windows PerformanceCounters
332+
* `QuickPulseTelemetryModule`: Collects telemetry for showing in Live Metrics portal
333+
* `AppServicesHeartbeatTelemetryModule`: Collects heart beats (which are sent as custom metrics), about Azure App Service environment where application is hosted
334+
* `AzureInstanceMetadataTelemetryModule`: Collects heart beats (which are sent as custom metrics), about Azure VM environment where application is hosted
335+
* `EventCounterCollectionModule`: Collects [EventCounters](eventcounters.md); this module is a new feature and is available in SDK version 2.8.0 and later
336336

337337
To configure any default `TelemetryModule`, use the extension method `ConfigureTelemetryModule<T>` on `IServiceCollection`, as shown in the following example.
338338

@@ -408,7 +408,7 @@ If you want to disable telemetry conditionally and dynamically, you can resolve
408408
}
409409
```
410410

411-
The preceding code sample prevents the sending of telemetry to Application Insights. It doesn't prevent any automatic collection modules from collecting telemetry. If you want to remove a particular auto collection module, see [remove the telemetry module](#configuring-or-removing-default-telemetrymodules).
411+
The preceding code sample prevents the sending of telemetry to Application Insights. It doesn't prevent any automatic collection modules from collecting telemetry. If you want to remove a particular auto collection module, see [Remove the telemetry module](#configuring-or-removing-default-telemetrymodules).
412412

413413
## Frequently asked questions
414414

@@ -449,8 +449,8 @@ For more information about custom data reporting in Application Insights, see [A
449449

450450
### How do I customize ILogger logs collection?
451451

452-
By default, only `Warning` logs and more severe logs are automatically captured. To change this behavior, explicitly override the logging configuration for the provider `ApplicationInsights` as shown below.
453-
The following configuration allows ApplicationInsights to capture all `Information` logs and more severe logs.
452+
By default, only `Warning` logs and more severe logs are automatically captured. To change this behavior, explicitly override the logging configuration for the provider `ApplicationInsights` as shown in the following code.
453+
The following configuration allows Application Insights to capture all `Information` logs and more severe logs.
454454

455455
```json
456456
{
@@ -467,7 +467,7 @@ The following configuration allows ApplicationInsights to capture all `Informati
467467
}
468468
```
469469

470-
It's important to note that the following example doesn't cause the ApplicationInsights provider to capture `Information` logs. It doesn't capture it because the SDK adds a default logging filter that instructs `ApplicationInsights` to capture only `Warning` logs and more severe logs. ApplicationInsights requires an explicit override.
470+
It's important to note that the following example doesn't cause the Application Insights provider to capture `Information` logs. It doesn't capture it because the SDK adds a default logging filter that instructs `ApplicationInsights` to capture only `Warning` logs and more severe logs. Application Insights requires an explicit override.
471471

472472
```json
473473
{
@@ -507,30 +507,30 @@ If the SDK is installed at build time as shown in this article, you don't need t
507507

508508
Yes. Feature support for the SDK is the same in all platforms, with the following exceptions:
509509

510-
* The SDK collects [Event Counters](./eventcounters.md) on Linux because [Performance Counters](./performance-counters.md) are only supported in Windows. Most metrics are the same.
510+
* The SDK collects [event counters](./eventcounters.md) on Linux because [performance counters](./performance-counters.md) are only supported in Windows. Most metrics are the same.
511511
* Although `ServerTelemetryChannel` is enabled by default, if the application is running in Linux or macOS, the channel doesn't automatically create a local storage folder to keep telemetry temporarily if there are network issues. Because of this limitation, telemetry is lost when there are temporary network or server issues. To work around this issue, configure a local folder for the channel:
512512

513-
```csharp
514-
using Microsoft.ApplicationInsights.Channel;
515-
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
516-
517-
public void ConfigureServices(IServiceCollection services)
518-
{
519-
// The following will configure the channel to use the given folder to temporarily
520-
// store telemetry items during network or Application Insights server issues.
521-
// User should ensure that the given folder already exists
522-
// and that the application has read/write permissions.
523-
services.AddSingleton(typeof(ITelemetryChannel),
524-
new ServerTelemetryChannel () {StorageFolder = "/tmp/myfolder"});
525-
services.AddApplicationInsightsTelemetry();
526-
}
527-
```
513+
```csharp
514+
using Microsoft.ApplicationInsights.Channel;
515+
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
516+
517+
public void ConfigureServices(IServiceCollection services)
518+
{
519+
// The following will configure the channel to use the given folder to temporarily
520+
// store telemetry items during network or Application Insights server issues.
521+
// User should ensure that the given folder already exists
522+
// and that the application has read/write permissions.
523+
services.AddSingleton(typeof(ITelemetryChannel),
524+
new ServerTelemetryChannel () {StorageFolder = "/tmp/myfolder"});
525+
services.AddApplicationInsightsTelemetry();
526+
}
527+
```
528528

529529
This limitation isn't applicable from version [2.15.0](https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore/2.15.0) and later.
530530
531531
### Is this SDK supported for the new .NET Core 3.X Worker Service template applications?
532532

533-
This SDK requires `HttpContext`; therefore, it doesn't work in any non-HTTP applications, including the .NET Core 3.X Worker Service applications. To enable Application Insights in such applications using the newly released Microsoft.ApplicationInsights.WorkerService SDK, see [Application Insights for Worker Service applications (non-HTTP applications)](worker-service.md).
533+
This SDK requires `HttpContext`. Therefore, it doesn't work in any non-HTTP applications, including the .NET Core 3.X Worker Service applications. To enable Application Insights in such applications using the newly released Microsoft.ApplicationInsights.WorkerService SDK, see [Application Insights for Worker Service applications (non-HTTP applications)](worker-service.md).
534534

535535
## Open-source SDK
536536

@@ -544,4 +544,4 @@ For the latest updates and bug fixes, see the [release notes](./release-notes.md
544544
* [Configure a snapshot collection](./snapshot-debugger.md) to see the state of source code and variables at the moment an exception is thrown.
545545
* [Use the API](./api-custom-events-metrics.md) to send your own events and metrics for a detailed view of your app's performance and usage.
546546
* Use [availability tests](./monitor-web-app-availability.md) to check your app constantly from around the world.
547-
* [Dependency Injection in ASP.NET Core](/aspnet/core/fundamentals/dependency-injection)
547+
* [Dependency Injection in ASP.NET Core](/aspnet/core/fundamentals/dependency-injection)

0 commit comments

Comments
 (0)