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: articles/azure-monitor/profiler/profiler-trackrequests.md
+14-7Lines changed: 14 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,19 +3,19 @@ title: Write code to track requests with Azure Application Insights | Microsoft
3
3
description: Write code to track requests with Application Insights so you can get profiles for your requests.
4
4
ms.topic: conceptual
5
5
ms.custom: devx-track-csharp
6
-
ms.date: 08/06/2018
7
-
ms.reviewer: jogrima
6
+
ms.date: 08/09/2022
7
+
ms.reviewer: charles.weininger
8
8
---
9
9
10
10
# Write code to track requests with Application Insights
11
11
12
-
To view profiles for your application on the Performance page, Azure Application Insights needs to track requests for your application. Application Insights can automatically track requests for applications that are built on already-instrumented frameworks. Two examples are ASP.NET and ASP.NET Core.
12
+
Azure Application Insights needs to track requests for your application in order to provide profiles for your application on the Performance page in the Azure portal.
13
13
14
-
For other applications, such as Azure Cloud Services worker roles and Service Fabric stateless APIs, you need to write code to tell Application Insights where your requests begin and end. After you've written this code, requests telemetry is sent to Application Insights. You can view the telemetry on the Performance page, and profiles are collected for those requests.
14
+
For applications built on already-instrumented frameworks (like ASP.NET and ASP.NET Core)S, Application Insightscan automatically track requests.
But for other applications (like Azure Cloud Services worker roles and Service Fabric stateless APIs), you need to track requests with code that tells Application Insights where your requests begin and end. Requests telemetry is then sent to Application Insights, which you can view on the Performance page. Profiles are collected for those requests.
17
17
18
-
To manually track requests, do the following:
18
+
To manually track requests:
19
19
20
20
1. Early in the application lifetime, add the following code:
21
21
@@ -25,6 +25,7 @@ To manually track requests, do the following:
25
25
// Replace with your own Application Insights instrumentation key.
For more information about this global instrumentation key configuration, see [Use Service Fabric with Application Insights](https://github.com/Azure-Samples/service-fabric-dotnet-getting-started/blob/dev/appinsights/ApplicationInsights.md).
29
30
30
31
1. For any piece of code that you want to instrument, add a `StartOperation<RequestTelemetry>`**using** statement around it, as shown in the following example:
@@ -41,7 +42,7 @@ To manually track requests, do the following:
41
42
}
42
43
```
43
44
44
-
Calling `StartOperation<RequestTelemetry>` within another `StartOperation<RequestTelemetry>` scope isn't supported. You can use `StartOperation<DependencyTelemetry>` in the nested scope instead. For example:
45
+
Calling `StartOperation<RequestTelemetry>` within another `StartOperation<RequestTelemetry>` scope isn't supported. You can use `StartOperation<DependencyTelemetry>` in the nested scope instead. For example:
45
46
46
47
```csharp
47
48
using (var getDetailsOperation = client.StartOperation<RequestTelemetry>("GetProductDetails"))
@@ -81,3 +82,9 @@ To manually track requests, do the following:
0 commit comments