-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported Tingle.AspNetCore.ApplicationInsights
- Loading branch information
1 parent
c4b5075
commit 54c541a
Showing
22 changed files
with
827 additions
and
0 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
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
11 changes: 11 additions & 0 deletions
11
samples/ApplicationInsightsSample/ApplicationInsightsSample.csproj
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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Tingle.AspNetCore.ApplicationInsights\Tingle.AspNetCore.ApplicationInsights.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
32 changes: 32 additions & 0 deletions
32
samples/ApplicationInsightsSample/Controllers/ValuesController.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,32 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
#pragma warning disable IDE0060 // Remove unused parameter | ||
|
||
namespace ApplicationInsightsSample.Controllers; | ||
|
||
[Route("api/[controller]")] | ||
[ApiController] | ||
[TrackProblems] | ||
public class ValuesController : ControllerBase | ||
{ | ||
// GET: api/Values | ||
[HttpGet] | ||
public IEnumerable<string> Get() | ||
{ | ||
return new string[] { "value1", "value2" }; | ||
} | ||
|
||
// GET: api/Values/5 | ||
[HttpGet("{id}", Name = "Get")] | ||
public string Get(int id) | ||
{ | ||
return "value"; | ||
} | ||
|
||
// POST: api/Values | ||
[HttpPost] | ||
public IActionResult Post([FromBody] string value) | ||
{ | ||
return Problem(title: "test_error_code", detail: "This is a test error", statusCode: 400); | ||
} | ||
} |
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,16 @@ | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.Services.AddApplicationInsightsTelemetry() | ||
.AddApplicationInsightsTelemetryHeaders() | ||
.AddApplicationInsightsTelemetryExtras(); | ||
|
||
builder.Services.AddControllers() | ||
.AddControllersAsServices(); | ||
|
||
var app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
|
||
app.MapControllers(); | ||
|
||
app.Run(); |
27 changes: 27 additions & 0 deletions
27
samples/ApplicationInsightsSample/Properties/launchSettings.json
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 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:50073", | ||
"sslPort": 44328 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"ApplicationInsightsSample": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:5001;http://localhost:5000", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
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,19 @@ | ||
##USAGE | ||
|
||
## Application Insights Instrumentation Key | ||
Get the key for your ApplicationInsights resource on Azure. | ||
|
||
Either replace the `00000000-0000-0000-0000-000000000000` in `appsettings.json` with the key, | ||
or configure it using the user-secret command, e.g.: | ||
|
||
dotnet user-secrets set AppSettings:YouTubeApiKey <app-server-key> | ||
|
||
|
||
## Running the sample | ||
|
||
1. Run the application (F5), | ||
2. Make a HTTP GET request to https://{your-endpoint}/api/values e.g. `https://localhost:50073/api/values` | ||
3. Make a HTTP POST request to https://{your-endpoint}/api/values e.g. `https://localhost:50073/api/values` | ||
4. Wait for about 2 minutes and check the insights for both requests | ||
5. The failed request should have more data e.g. `Client`, `IpAddress`, `problem.title`, 'problem.detail', `headers` e.t.c. | ||
|
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,13 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft": "Warning", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
|
||
// replace the key below with the actual instrumentation key, or set it in the secrets | ||
"ApplicationInsights:InstrumentationKey": "00000000-0000-0000-0000-000000000000" | ||
} |
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
Oops, something went wrong.