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/insights/code-optimizations.md
+7-68Lines changed: 7 additions & 68 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,22 +6,18 @@ ms.service: azure-monitor
6
6
ms.subservice: optimization-insights
7
7
author: hhunter-ms
8
8
ms.author: hannahhunter
9
-
ms.date: 07/24/2023
9
+
ms.date: 03/08/2024
10
10
ms.reviewer: ryankahng
11
11
---
12
12
13
13
# Monitor and analyze runtime behavior with Code Optimizations (Preview)
14
14
15
-
Code Optimizations, an AI-based service in Azure Application Insights, works in tandem with the Application Insights Profiler to help you help create better and more efficient applications.
16
-
17
-
With its advanced AI algorithms, Code Optimizations detects CPU and memory usage performance issues at a code level and provides recommendations on how to fix them. Code Optimizations identifies these CPU and memory bottlenecks by:
15
+
Code Optimizations, an AI-based service in Azure Application Insights, works in tandem with the Application Insights Profiler to detect CPU and memory usage performance issues at a code level and provide recommendations on how to fix them. Code Optimizations identifies these CPU and memory bottlenecks by:
18
16
19
17
- Analyzing the runtime behavior of your application.
20
18
- Comparing the behavior to performance engineering best practices.
21
19
22
-
With Code Optimizations, you can:
23
-
- View real-time performance data and insights gathered from your production environment.
24
-
- Make informed decisions about optimizing your code.
20
+
Make informed decisions and optimize your code using real-time performance data and insights gathered from your production environment.
25
21
26
22
## Demo video
27
23
@@ -65,70 +61,13 @@ az account list-locations -o table
65
61
66
62
You can set an explicit region using connection strings. [Learn more about connection strings with examples.](../app/sdk-connection-string.md#connection-string-examples)
67
63
68
-
## Access Code Optimizations results
69
-
70
-
You can access Code Optimizations through the **Performance** blade from the left navigation pane and select **Code Optimizations (preview)** from the top menu.
71
-
72
-
:::image type="content" source="./media/code-optimizations/code-optimizations-performance-blade.png" alt-text="Screenshot of Code Optimizations located in the Performance blade.":::
73
-
74
-
### Interpret estimated Memory and CPU percentages
75
-
76
-
The estimated CPU and Memory are determined based on the amount of activity in your application. In addition to the Memory and CPU percentages, Code Optimizations also includes:
77
-
78
-
- The actual allocation sizes (in bytes)
79
-
- A breakdown of the allocated types made within the call
80
-
81
-
#### Memory
82
-
For Memory, the number is just a percentage of all allocations made within the trace. For example, if an issue takes 24% memory, you spent 24% of all your allocations within that call.
83
-
84
-
#### CPU
85
-
For CPU, the percentage is based on the number of CPUs in your machine (four core, eight core, etc.) and the trace time. For example, let's say your trace is 10 seconds long and you have 4 CPUs, you have a total of 40 seconds of CPU time. If the insight says the line of code is using 5% of the CPU, it’s using 5% of 40 seconds, or 2 seconds.
86
-
87
-
### Filter and sort results
88
-
89
-
On the Code Optimizations page, you can filter the results by:
90
-
91
-
- Using the search bar to filter by field.
92
-
- Setting the time range via the **Time Range** drop-down menu.
93
-
- Selecting the corresponding role from the **Role** drop-down menu.
94
-
95
-
You can also sort columns in the insights results based on:
96
-
97
-
- Type (memory or CPU).
98
-
- Issue frequency within a specific time period (count).
99
-
- Corresponding role, if your service has multiple roles (role).
100
-
101
-
:::image type="content" source="./media/code-optimizations/code-optimizations-filter.png" alt-text="Screenshot of available filters for Code Optimizations results.":::
102
-
103
-
### View insights
104
-
105
-
After sorting and filtering the Code Optimizations results, you can then select each insight to view the following details in a pane:
106
-
107
-
- Detailed description of the performance bug insight.
108
-
- The full call stack.
109
-
- Recommendations on how to fix the performance issue.
110
-
111
-
:::image type="content" source="./media/code-optimizations/code-optimizations-details.png" alt-text="Screenshot of the detail pane for a specific Code Optimizations C-P-U result.":::
112
-
113
-
#### Call stack
114
-
115
-
In the insights details pane, under the **Call Stack** heading, you can:
116
-
117
-
- Select **Expand** to view the full call stack surrounding the performance issue
118
-
- Select **Copy** to copy the call stack.
119
-
120
-
:::image type="content" source="./media/code-optimizations/code-optimizations-call-stack-2.png" alt-text="Screenshot of the call stack heading in the detail pane for the specific C-P-U result from earlier.":::
121
-
122
-
:::image type="content" source="./media/code-optimizations/code-optimizations-call-stack.png" alt-text="Screenshot of the expanded call stack for the specific C-P-U result from earlier.":::
123
-
124
-
#### Trend impact
125
-
126
-
You can also view a graph depicting a specific performance issue's impact and threshold. The trend impact results vary depending on the filters you've set. For example, a CPU `String.SubString()` performance issue's insights seen over a seven day time frame may look like:
64
+
## Next steps
127
65
128
-
:::image type="content" source="./media/code-optimizations/code-optimizations-trend-impact.png" alt-text="Screenshot of the C-P-U trend impact over the course of seven days.":::
66
+
> [!div class="nextstepaction"]
67
+
> [Set up Code Optimizations](set-up-code-optimizations.md)
129
68
130
69
131
-
## Next Steps
70
+
## Related links
132
71
133
72
Get started with Code Optimizations by enabling the following features on your application:
description: Learn how to enable and set up Azure Monitor's Code Optimizations feature.
4
+
ms.topic: conceptual
5
+
ms.service: azure-monitor
6
+
ms.subservice: optimization-insights
7
+
author: hhunter-ms
8
+
ms.author: hannahhunter
9
+
ms.date: 03/08/2024
10
+
ms.reviewer: ryankahng
11
+
---
12
+
13
+
# Set up Code Optimizations (Preview)
14
+
15
+
Setting up Code Optimizations to identify and analyze CPU and memory bottlenecks in your web applications is a simple process in the Azure portal. In this guide, you learn how to:
16
+
17
+
- Connect your web app to Application Insights.
18
+
- Enable the Profiler on your web app.
19
+
20
+
## Demo video
21
+
22
+
<iframewidth="560"height="315"src="https://www.youtube-nocookie.com/embed/vbi9YQgIgC8"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"allowfullscreen></iframe>
23
+
24
+
## Connect your web app to Application Insights
25
+
26
+
Before setting up Code Optimizations for your web app, ensure that your app is connected to an Application Insights resource.
27
+
28
+
1. In the Azure portal, navigate to your web application.
29
+
1. From the left menu, select **Settings** > **Application Insights**.
30
+
1. In the Application Insights blade for your web application, determine the following options:
31
+
32
+
-**If your web app is already connected to an Application Insights resource:**
33
+
- A banner at the top of the blade reads: **Your app is connected to Application Insights resource: {NAME-OF-RESOURCE}**.
34
+
35
+
:::image type="content" source="media/set-up-code-optimizations/already-enabled-app-insights.png" alt-text="Screenshot of the banner explaining that your app is already connected to App Insights.":::
36
+
37
+
-**If your web app still needs to be connected to an Application Insights resource:**
38
+
- A banner at the top of the blade reads: **Your app will be connected to an auto-created Application Insights resource: {NAME-OF-RESOURCE}**.
39
+
40
+
:::image type="content" source="media/set-up-code-optimizations/need-to-enable-app-insights.png" alt-text="Screenshot of the banner telling you to enable App Insights and the name of the App Insights resource.":::
41
+
42
+
1. Click **Apply** at the bottom of the Application Insights pane.
43
+
44
+
## Enable Profiler on your web app
45
+
46
+
Profiler collects traces on your web app for Code Optimizations to analyze. In a few hours, if Code Optimization notices any performance bottlenecks in your application, you can see and review Code Optimizations insights.
47
+
48
+
1. Still in the Application Insights blade, under **Instrument your application**, select the **.NET** tab.
49
+
1. Under **Profiler**, select the toggle to turn on Profiler for your web app.
50
+
51
+
:::image type="content" source="media/set-up-code-optimizations/enable-profiler.png" alt-text="Screenshot of how to enable Profiler for your web app.":::
52
+
53
+
1. Verify the Profiler is collecting traces.
54
+
1. Navigate to your Application Insights resource.
55
+
1. From the left menu, select **Investigate** > **Performance**.
56
+
1. In the Performance blade, select **Profiler** from the top menu.
57
+
1. Review the profiler traces collected from your web app. [If you don't see any traces, see the troubleshooting guide](../profiler/profiler-troubleshooting.md).
description: Learn how to access the results provided by Azure Monitor's Code Optimizations feature.
4
+
ms.topic: conceptual
5
+
ms.service: azure-monitor
6
+
ms.subservice: optimization-insights
7
+
author: hhunter-ms
8
+
ms.author: hannahhunter
9
+
ms.date: 03/05/2024
10
+
ms.reviewer: ryankahng
11
+
---
12
+
13
+
# View Code Optimizations results (Preview)
14
+
15
+
Now that you set up and configured Code Optimizations on your app, access and view any insights you received via the Azure portal. You can access Code Optimizations through the **Performance** blade from the left navigation pane and select **Code Optimizations (preview)** from the top menu.
16
+
17
+
:::image type="content" source="./media/code-optimizations/code-optimizations-performance-blade.png" alt-text="Screenshot of Code Optimizations located in the Performance blade.":::
18
+
19
+
## Interpret estimated Memory and CPU percentages
20
+
21
+
The estimated CPU and Memory are determined based on the amount of activity in your application. In addition to the Memory and CPU percentages, Code Optimizations also includes:
22
+
23
+
- The actual allocation sizes (in bytes)
24
+
- A breakdown of the allocated types made within the call
25
+
26
+
### Memory
27
+
For Memory, the number is just a percentage of all allocations made within the trace. For example, if an issue takes 24% memory, you spent 24% of all your allocations within that call.
28
+
29
+
### CPU
30
+
For CPU, the percentage is based on the number of CPUs in your machine (four core, eight core, etc.) and the trace time. For example, let's say your trace is 10 seconds long and you have 4 CPUs: you have a total of 40 seconds of CPU time. If the insight says the line of code is using 5% of the CPU, it’s using 5% of 40 seconds, or 2 seconds.
31
+
32
+
## Filter and sort results
33
+
34
+
On the Code Optimizations page, you can filter the results by:
35
+
36
+
- Using the search bar to filter by field.
37
+
- Setting the time range via the **Time Range** drop-down menu.
38
+
- Selecting the corresponding role from the **Role** drop-down menu.
39
+
40
+
You can also sort columns in the insights results based on:
41
+
42
+
- Type (memory or CPU).
43
+
- Issue frequency within a specific time period (count).
44
+
- Corresponding role, if your service has multiple roles (role).
45
+
46
+
:::image type="content" source="./media/code-optimizations/code-optimizations-filter.png" alt-text="Screenshot of available filters for Code Optimizations results.":::
47
+
48
+
## View insights
49
+
50
+
After sorting and filtering the Code Optimizations results, you can then select each insight to view the following details in a pane:
51
+
52
+
- Detailed description of the performance bug insight.
53
+
- The full call stack.
54
+
- Recommendations on how to fix the performance issue.
55
+
56
+
:::image type="content" source="./media/code-optimizations/code-optimizations-details.png" alt-text="Screenshot of the detail pane for a specific Code Optimizations C-P-U result.":::
57
+
58
+
> [!NOTE]
59
+
> If you don't see any insights, it's likely that the Code Optimizations service hasn't noticed any performance bottlenecks in your code. Continue to check back to see if any insights pop up.
60
+
61
+
### Call stack
62
+
63
+
In the insights details pane, under the **Call Stack** heading, you can:
64
+
65
+
- Select **Expand** to view the full call stack surrounding the performance issue
66
+
- Select **Copy** to copy the call stack.
67
+
68
+
:::image type="content" source="./media/code-optimizations/code-optimizations-call-stack-2.png" alt-text="Screenshot of the call stack heading in the detail pane for the specific C-P-U result from earlier.":::
69
+
70
+
:::image type="content" source="./media/code-optimizations/code-optimizations-call-stack.png" alt-text="Screenshot of the expanded call stack for the specific C-P-U result from earlier.":::
71
+
72
+
### Trend impact
73
+
74
+
You can also view a graph depicting a specific performance issue's impact and threshold. The trend impact results vary depending on the filters you set. For example, a CPU `String.SubString()` performance issue's insights seen over a seven day time frame may look like:
75
+
76
+
:::image type="content" source="./media/code-optimizations/code-optimizations-trend-impact.png" alt-text="Screenshot of the C-P-U trend impact over the course of seven days.":::
0 commit comments