Skip to content

Commit

Permalink
Add Application Insights telemetry configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
0GiS0 committed Feb 19, 2024
1 parent 26fe067 commit 4d75f44
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
6 changes: 6 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
});


/************************************************************************************************/
/********************************** Application Insights ****************************************/
/************************************************************************************************/

builder.Services.AddApplicationInsightsTelemetry(); //You need ApplicationInsights.ConnectionString in your appsettings.json

/************************************************************************************************
********************************** Open Telemetry configuration *********************************
*********** https://grafana.com/grafana/dashboards/17706-asp-net-otel-metrics/ ******************
Expand Down
29 changes: 16 additions & 13 deletions appsettings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"ConnectionStrings": {
"DefaultConnection": "<AZURE_SQL_DATABASE>",
"AzureStorage": ""
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
"ConnectionStrings": {
"DefaultConnection": "<AZURE_SQL_DATABASE>",
"AzureStorage": ""
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=3faddc52-30e5-46dc-801f-c2a46c197ade;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/"
},
"AllowedHosts": "*"
}
3 changes: 3 additions & 0 deletions tour-of-heroes-api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.6.0-rc.1" />

<!-- Application Insights -->
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />

</ItemGroup>

</Project>

0 comments on commit 4d75f44

Please sign in to comment.