Plex.App.Insights.Core
2.22.13
dotnet add package Plex.App.Insights.Core --version 2.22.13
NuGet\Install-Package Plex.App.Insights.Core -Version 2.22.13
<PackageReference Include="Plex.App.Insights.Core" Version="2.22.13" />
<PackageVersion Include="Plex.App.Insights.Core" Version="2.22.13" />
<PackageReference Include="Plex.App.Insights.Core" />
paket add Plex.App.Insights.Core --version 2.22.13
#r "nuget: Plex.App.Insights.Core, 2.22.13"
#:package Plex.App.Insights.Core@2.22.13
#addin nuget:?package=Plex.App.Insights.Core&version=2.22.13
#tool nuget:?package=Plex.App.Insights.Core&version=2.22.13
Plex.App.Insights.Core
A .NET 8 library that provides a single-call extension method to wire up OpenTelemetry-based Application Insights telemetry (traces and metrics) for ASP.NET Core applications.
Features
- One-line setup —
builder.AddAppInsights()configures everything - OpenTelemetry-based — uses the modern OpenTelemetry SDK with Azure Monitor exporters
- Tracing — ASP.NET Core (inbound HTTP), HTTP client (outbound HTTP), and SQL client instrumentation
- Metrics — ASP.NET Core hosting, Kestrel server, and HTTP client metrics
- SQL command capture — optionally includes SQL command text in traces
- Cloud role naming — configures
service.name,service.instance.id, andservice.versionas OpenTelemetry resource attributes - Safe no-op — gracefully skips registration when
APPLICATIONINSIGHTS_CONNECTION_STRINGis not set
Installation
dotnet add package Plex.App.Insights.Core
Configuration
Set the Application Insights connection string as an environment variable:
APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...;IngestionEndpoint=...
Add optional settings to your appsettings.json:
{
"AppSettings": {
"CloudRoleName": "my-service",
"CloudRoleInstance": "instance-01",
"CloudRoleVersion": "1.0.0",
"EnableSqlCommandTextInstrumentation": "true"
}
}
| Setting | Default | Description |
|---|---|---|
CloudRoleName |
— | Sets the service.name resource attribute (identifies the service in Application Insights) |
CloudRoleInstance |
— | Sets the service.instance.id resource attribute |
CloudRoleVersion |
— | Sets the service.version resource attribute |
EnableSqlCommandTextInstrumentation |
false |
When true, captures SQL command text (db.query.text) in traces |
Usage
var builder = WebApplication.CreateBuilder(args);
builder.AddAppInsights();
var app = builder.Build();
This registers:
Tracing:
- ASP.NET Core instrumentation (inbound HTTP requests)
- HTTP client instrumentation (outbound HTTP calls)
- SQL client instrumentation (with optional command text capture)
- Azure Monitor trace exporter
Metrics:
Microsoft.AspNetCore.Hosting(request metrics)Microsoft.AspNetCore.Server.Kestrel(server metrics)System.Net.Http(HTTP client metrics)- Azure Monitor metric exporter
If APPLICATIONINSIGHTS_CONNECTION_STRING is not set, the method is a no-op — safe to call in all environments.
Dependencies
| Package | Version |
|---|---|
| Azure.Monitor.OpenTelemetry.Exporter | 1.8.x |
| OpenTelemetry.Instrumentation.AspNetCore | 1.17.x |
| OpenTelemetry.Instrumentation.Http | 1.17.x |
| OpenTelemetry.Instrumentation.SqlClient | 1.17.x |
| Plex.Extensions.Configuration | 8.0.x |
License
Plex-Solution Community Source-Available License — free for non-commercial use only.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.8.2)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.17.0)
- OpenTelemetry.Instrumentation.Http (>= 1.17.0)
- OpenTelemetry.Instrumentation.SqlClient (>= 1.17.0)
- Plex.Extensions.Configuration (>= 8.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Update vulnerabilities packages