Skip to content

Commit

Permalink
Imported Tingle.AspNetCore.ApplicationInsights
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Mar 19, 2024
1 parent c4b5075 commit 54c541a
Show file tree
Hide file tree
Showing 22 changed files with 827 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
fail-fast: true
matrix:
suite:
- { name: 'Tingle.AspNetCore.ApplicationInsights' }
- { name: 'Tingle.AspNetCore.Authentication' }
- { name: 'Tingle.AspNetCore.Authorization' }
- { name: 'Tingle.AspNetCore.DataProtection.MongoDB' }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This repository contains projects/libraries for adding useful functionality to .

|Package|Description|
|--|--|
|[`Tingle.AspNetCore.ApplicationInsights`](https://www.nuget.org/packages/Tingle.AspNetCore.ApplicationInsights/)|Convenience functionality for Application Insights on AspNetCore such as collecting problem details. See [docs](./src/Tingle.AspNetCore.ApplicationInsights/README.md) and [sample](./samples/ApplicationInsightsSample)|
|[`Tingle.AspNetCore.Authentication`](https://www.nuget.org/packages/Tingle.AspNetCore.Authentication/)|Convenience authentication functionality such as pass through and pre-shared key authentication mechanisms. See [docs](./src/Tingle.AspNetCore.Authentication/README.md) and [sample](./samples/AuthenticationSample)|
|[`Tingle.AspNetCore.Authorization`](https://www.nuget.org/packages/Tingle.AspNetCore.Authorization/)|Additional authorization functionality such as handlers and requirements. See [docs](./src/Tingle.AspNetCore.Authorization/README.md) and [sample](./samples/AuthorizationSample)|
|[`Tingle.AspNetCore.DataProtection.MongoDB`](https://www.nuget.org/packages/Tingle.AspNetCore.DataProtection.MongoDB/)|Data Protection store in [MongoDB](https://mongodb.com) for ASP.NET Core. See [docs](./src/Tingle.AspNetCore.DataProtection.MongoDB/README.md) and [sample](./samples/DataProtectionMongoDBSample).|
Expand Down
21 changes: 21 additions & 0 deletions Tingle.Extensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9546186D-D4E
src\Directory.Build.props = src\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AspNetCore.ApplicationInsights", "src\Tingle.AspNetCore.ApplicationInsights\Tingle.AspNetCore.ApplicationInsights.csproj", "{644FFD56-7880-4EFB-BBB1-E29FC7EBFD3F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AspNetCore.Authentication", "src\Tingle.AspNetCore.Authentication\Tingle.AspNetCore.Authentication.csproj", "{98F3A2B7-5774-4E38-8FA0-FA13B6134454}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AspNetCore.Authorization", "src\Tingle.AspNetCore.Authorization\Tingle.AspNetCore.Authorization.csproj", "{22690754-DCFB-4CD2-968D-239C1952B52C}"
Expand Down Expand Up @@ -49,6 +51,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{815F0941
tests\Directory.Build.props = tests\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AspNetCore.ApplicationInsights.Tests", "tests\Tingle.AspNetCore.ApplicationInsights.Tests\Tingle.AspNetCore.ApplicationInsights.Tests.csproj", "{6CD03B65-8D8F-42D4-8E81-33D9FD932AEE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AspNetCore.Authentication.Tests", "tests\Tingle.AspNetCore.Authentication.Tests\Tingle.AspNetCore.Authentication.Tests.csproj", "{A324CC70-36DD-4B38-9EC8-9069F6130FAC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tingle.AspNetCore.Authorization.Tests", "tests\Tingle.AspNetCore.Authorization.Tests\Tingle.AspNetCore.Authorization.Tests.csproj", "{E67CB6B9-6F42-4E63-9603-810B5B9FBF57}"
Expand Down Expand Up @@ -90,6 +94,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{CE71
samples\Directory.Build.props = samples\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationInsightsSample", "samples\ApplicationInsightsSample\ApplicationInsightsSample.csproj", "{3C4028B5-26F4-464A-9B0A-F2EA83E6C3C5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreSessionState", "samples\AspNetCoreSessionState\AspNetCoreSessionState.csproj", "{CEF2A8D5-771F-42A1-B61D-9DEA4AB1921C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AuthenticationSample", "samples\AuthenticationSample\AuthenticationSample.csproj", "{E04EC969-2539-46E9-B918-8C8B7BEB8828}"
Expand All @@ -116,6 +122,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{644FFD56-7880-4EFB-BBB1-E29FC7EBFD3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{644FFD56-7880-4EFB-BBB1-E29FC7EBFD3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{644FFD56-7880-4EFB-BBB1-E29FC7EBFD3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{644FFD56-7880-4EFB-BBB1-E29FC7EBFD3F}.Release|Any CPU.Build.0 = Release|Any CPU
{98F3A2B7-5774-4E38-8FA0-FA13B6134454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98F3A2B7-5774-4E38-8FA0-FA13B6134454}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98F3A2B7-5774-4E38-8FA0-FA13B6134454}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -188,6 +198,10 @@ Global
{29035EF2-2391-4441-AAC5-85AA43586EEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29035EF2-2391-4441-AAC5-85AA43586EEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29035EF2-2391-4441-AAC5-85AA43586EEB}.Release|Any CPU.Build.0 = Release|Any CPU
{6CD03B65-8D8F-42D4-8E81-33D9FD932AEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CD03B65-8D8F-42D4-8E81-33D9FD932AEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CD03B65-8D8F-42D4-8E81-33D9FD932AEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CD03B65-8D8F-42D4-8E81-33D9FD932AEE}.Release|Any CPU.Build.0 = Release|Any CPU
{A324CC70-36DD-4B38-9EC8-9069F6130FAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A324CC70-36DD-4B38-9EC8-9069F6130FAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A324CC70-36DD-4B38-9EC8-9069F6130FAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -260,6 +274,10 @@ Global
{8E611861-09A3-4AE4-8392-E7CB9BE02B3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E611861-09A3-4AE4-8392-E7CB9BE02B3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E611861-09A3-4AE4-8392-E7CB9BE02B3B}.Release|Any CPU.Build.0 = Release|Any CPU
{3C4028B5-26F4-464A-9B0A-F2EA83E6C3C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C4028B5-26F4-464A-9B0A-F2EA83E6C3C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C4028B5-26F4-464A-9B0A-F2EA83E6C3C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C4028B5-26F4-464A-9B0A-F2EA83E6C3C5}.Release|Any CPU.Build.0 = Release|Any CPU
{CEF2A8D5-771F-42A1-B61D-9DEA4AB1921C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEF2A8D5-771F-42A1-B61D-9DEA4AB1921C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEF2A8D5-771F-42A1-B61D-9DEA4AB1921C}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -301,6 +319,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{644FFD56-7880-4EFB-BBB1-E29FC7EBFD3F} = {9546186D-D4E1-4EDB-956E-1F81C7F4DB72}
{98F3A2B7-5774-4E38-8FA0-FA13B6134454} = {9546186D-D4E1-4EDB-956E-1F81C7F4DB72}
{22690754-DCFB-4CD2-968D-239C1952B52C} = {9546186D-D4E1-4EDB-956E-1F81C7F4DB72}
{6F93ED1D-6475-46F2-A7DB-B2A5F9DB5A83} = {9546186D-D4E1-4EDB-956E-1F81C7F4DB72}
Expand All @@ -319,6 +338,7 @@ Global
{A803DE4B-B050-48F2-82A1-8E947D8FB96C} = {9546186D-D4E1-4EDB-956E-1F81C7F4DB72}
{6A1901A5-D01F-47E2-9ED5-2BE4CCE95100} = {9546186D-D4E1-4EDB-956E-1F81C7F4DB72}
{29035EF2-2391-4441-AAC5-85AA43586EEB} = {9546186D-D4E1-4EDB-956E-1F81C7F4DB72}
{6CD03B65-8D8F-42D4-8E81-33D9FD932AEE} = {815F0941-3B70-4705-A583-AF627559595C}
{A324CC70-36DD-4B38-9EC8-9069F6130FAC} = {815F0941-3B70-4705-A583-AF627559595C}
{E67CB6B9-6F42-4E63-9603-810B5B9FBF57} = {815F0941-3B70-4705-A583-AF627559595C}
{E28F4E8D-148B-4583-A27D-E1DA2CC08167} = {815F0941-3B70-4705-A583-AF627559595C}
Expand All @@ -337,6 +357,7 @@ Global
{978023EA-2ED5-4A28-96AD-4BB914EF2BE5} = {815F0941-3B70-4705-A583-AF627559595C}
{A8AB6597-DEBB-4828-AE1B-A11FD818E428} = {815F0941-3B70-4705-A583-AF627559595C}
{8E611861-09A3-4AE4-8392-E7CB9BE02B3B} = {815F0941-3B70-4705-A583-AF627559595C}
{3C4028B5-26F4-464A-9B0A-F2EA83E6C3C5} = {CE7124E9-01B3-4AD6-8B8F-FB302E60FB7F}
{CEF2A8D5-771F-42A1-B61D-9DEA4AB1921C} = {CE7124E9-01B3-4AD6-8B8F-FB302E60FB7F}
{E04EC969-2539-46E9-B918-8C8B7BEB8828} = {CE7124E9-01B3-4AD6-8B8F-FB302E60FB7F}
{B97964EC-658A-4205-AA5A-BB814B191C35} = {CE7124E9-01B3-4AD6-8B8F-FB302E60FB7F}
Expand Down
11 changes: 11 additions & 0 deletions samples/ApplicationInsightsSample/ApplicationInsightsSample.csproj
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 samples/ApplicationInsightsSample/Controllers/ValuesController.cs
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);
}
}
16 changes: 16 additions & 0 deletions samples/ApplicationInsightsSample/Program.cs
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 samples/ApplicationInsightsSample/Properties/launchSettings.json
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"
}
}
}
}
19 changes: 19 additions & 0 deletions samples/ApplicationInsightsSample/README.md
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.

13 changes: 13 additions & 0 deletions samples/ApplicationInsightsSample/appsettings.json
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"
}
1 change: 1 addition & 0 deletions samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<PropertyGroup>
<NoWarn>$(NoWarn);CA1822;CA1031;IDE0060;IDE0059</NoWarn>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Loading

0 comments on commit 54c541a

Please sign in to comment.