-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update docuemnts for 1.1.6-beta1 * Add a quick start for .NET Core 3.0 app * Add migration documentations * Add simulate bottle neck for quick start 3.0 * Update readme for 2.0.0-beta1 * Update some wording for quick starts * Fix a typo
- Loading branch information
1 parent
98ec18e
commit 745ead5
Showing
20 changed files
with
569 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Migrating from Application Insights Profiler 1.x to 2.0 | ||
|
||
There are break changes between 1.x and 2.0 for Application Insights Profiler but the migration should be very easy. | ||
|
||
## Update the NuGet packages | ||
|
||
* To use .NET Core CLI: | ||
|
||
```shell | ||
dotnet add package Microsoft.ApplicationInsights.Profiler.AspNetCore --version 2.0.0-* | ||
``` | ||
|
||
* To use package manager: | ||
|
||
```shell | ||
Install-Package Microsoft.ApplicationInsights.Profiler.AspNetCore -Version 1.1.7-* | ||
``` | ||
|
||
## Update the configurations | ||
|
||
There are changes in the configurations. Refer to [What's new](./WhatIsNew2_0#New_customization_options) for details. The minimum step is to remove the obsoleted parameter named 'Interval' form the following location: | ||
|
||
1. appsettings.[Environment].json | ||
1. appsettings.json | ||
1. Update the method of `AddServiceProfiler` to remove the option of **Interval** if it is used. | ||
|
||
And that's it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# What is New in Application Insights Profiler 2.0.0 | ||
|
||
## Profiler Now | ||
|
||
The profiler is talking with the service profiler azure backend and will accept `Profile Now` requests from the portal. | ||
|
||
You can use the `Profile Now` button in the portal and review the traces from the Azure Portal. | ||
|
||
## New scheduling system | ||
|
||
**Random scheduling policy** is used to replace the old fixed time scheduling system. | ||
|
||
In previous versions (1.x), the scheduling system takes 3 parameters: initial delay, duration and interval. The Profiler will be started with an initial delay, run for duration and then pause for interval. | ||
|
||
It is replaced by a random scheduling system/policy. A new parameter of `RandomProfilingOverhead` has been introduced. The random scheduling policy will calculate the profiling count based on the request overhead. For example, to calculate for the next 24 hours: | ||
|
||
```shell | ||
dn / 60 = 24 * r | ||
``` | ||
|
||
In the formula above, `r` is the overhead rate, `d` is the duration, n is the number of profiling. Take duration of **2 minutes**, rate of **5%**, in the next **24 hours** as an example: | ||
|
||
```shell | ||
n = 24 * 0.05 * 60 / 2 = 36 | ||
``` | ||
|
||
Profiler will happen 36 times. | ||
|
||
Notices, depends on the traffic and sampling and other factors, the real trace you get may be less than 36. | ||
|
||
Also, if you watch carefully, you will see other scheduling policies like **OneTimeSchedulingPolicy**, which runs every time after the initial delay per app session. Profile Now is implemented by **OnDemandSchedulingPolicy**. | ||
|
||
## CPU / Memory trigger support for Apps running on Windows | ||
|
||
When Application Insights Profiler for ASP.NET Core NuGet package is included in an ASP.NET Core Application on **Windows**, **CPU triggers** and **Memory triggers** are supported. | ||
|
||
The threshold for the triggers are 80% by default. The trigger policy will look back for 30 second, get the average resource usage and compare it with the threshold. When the value goes beyond the threshold, profiling will be triggered. | ||
|
||
Notes: Although sharing the backend, this is different than the traditional Profiling [here](https://docs.microsoft.com/en-us/azure/azure-monitor/app/profiler-overview). | ||
|
||
## Better container support for .NET Core 3.0 Application | ||
|
||
* Uploaders for .NET Core Runtime 2.0 and .NET Core Runtime 3.0 are sim-shipped in the NuGet package. No more hacks needed to run the same profiler in both .NET Core 2.0 based containers as well as .NET Core 3.0 runtime based containers. | ||
|
||
* In the scenario where you want to pull down the uploader in your dockerfile directly, we are now uploading the exact same uploader binaries on GitHub. Check them out in [Releases](https://github.com/microsoft/ApplicationInsights-Profiler-AspNetCore/releases). | ||
|
||
## New customization options | ||
|
||
* There are changes of options to control the profiling: | ||
|
||
| Option | v2 | v1 | Remark | | ||
|-------------------------|---------|----------|---------------------------------------------------------------| | ||
| RandomProfilingOverhead | 0.05 | N/A | Random profiling overhead percentage in float. The default value of 0.05 means 5%. | | ||
| CPUTriggerThreshold | 0.80 | N/A | Windows only. Threshold for CPU profiling trigger. | | ||
| MemoryTriggerThreshold | 0.80 | N/A | Windows only. Threshold for memory profiling trigger. | | ||
| Interval | Removed | 00:58:00 | Intervals between profiling. Replaced by random policy. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin/ | ||
obj/ | ||
global.json | ||
nuget.config | ||
pkgs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
// Use IntelliSense to find out which attributes exist for C# debugging | ||
// Use hover for the description of the existing attributes | ||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Core Launch (web)", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
// If you have changed target frameworks, make sure to update the program path. | ||
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/QuickStart3_0.dll", | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"stopAtEntry": false, | ||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser | ||
"serverReadyAction": { | ||
"action": "openExternally", | ||
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)" | ||
}, | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"sourceFileMap": { | ||
"/Views": "${workspaceFolder}/Views" | ||
} | ||
}, | ||
{ | ||
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processId": "${command:pickProcess}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Build QuickStart for .NET Core 3.0", | ||
"command": "dotnet", | ||
"type": "process", | ||
"group": "build", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/QuickStart3_0.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
47 changes: 47 additions & 0 deletions
47
examples/QuickStart3_0/Controllers/WeatherForecastController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace QuickStart3_0.Controllers | ||
{ | ||
[ApiController] | ||
[Route("[controller]")] | ||
public class WeatherForecastController : ControllerBase | ||
{ | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
private readonly ILogger<WeatherForecastController> _logger; | ||
|
||
public WeatherForecastController(ILogger<WeatherForecastController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[HttpGet] | ||
public IEnumerable<WeatherForecast> Get() | ||
{ | ||
SimulateDelay(); | ||
var rng = new Random(); | ||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = DateTime.Now.AddDays(index), | ||
TemperatureC = rng.Next(-20, 55), | ||
Summary = Summaries[rng.Next(Summaries.Length)] | ||
}) | ||
.ToArray(); | ||
} | ||
|
||
private void SimulateDelay() | ||
{ | ||
// Delay for 500ms to 2s to simulate a bottleneck. | ||
Thread.Sleep((new Random()).Next(500, 2000)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace QuickStart3_0 | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureWebHostDefaults(webBuilder => | ||
{ | ||
webBuilder.UseStartup<Startup>(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.2" /> | ||
<PackageReference Include="Microsoft.ApplicationInsights.Profiler.AspNetCore" Version="2.0.0-*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.