APM-globalMiddleware
1.5.6
dotnet add package APM-globalMiddleware --version 1.5.6
NuGet\Install-Package APM-globalMiddleware -Version 1.5.6
<PackageReference Include="APM-globalMiddleware" Version="1.5.6" />
<PackageVersion Include="APM-globalMiddleware" Version="1.5.6" />
<PackageReference Include="APM-globalMiddleware" />
paket add APM-globalMiddleware --version 1.5.6
#r "nuget: APM-globalMiddleware, 1.5.6"
#:package APM-globalMiddleware@1.5.6
#addin nuget:?package=APM-globalMiddleware&version=1.5.6
#tool nuget:?package=APM-globalMiddleware&version=1.5.6
APM-globalMiddleware
APM-globalMiddleware is a .NET 10 and .NET 8 library that provides global middleware for Application Performance Monitoring (APM) in .NET applications. It integrates with Application Insights and Serilog for advanced telemetry and structured logging, and supports both Azure Functions and ASP.NET Core scenarios.
Features
- Automatic telemetry collection using Application Insights
- Structured logging with Serilog, including Application Insights sink support
- Middleware support for ASP.NET Core and Azure Functions
- OpenAPI integration
Getting Started
Prerequisites
- .NET 8.0 SDK or .NET 10 SDK
Installation
Using .NET CLI
dotnet add package APM-globalMiddleware
Using Package Manager
Install-Package APM-globalMiddleware
ASP.NET Core Example
var configuration = builder.Configuration;
Log.Logger = new LoggerConfiguration()
.APMLoggerEnricher(configuration, forwardsAllLogs: false) // if sets to true, all logs will be forwarded
.CreateLogger();
builder.Services.AddGlobalExceptionHandling(builder.Configuration);
app.UseGlobalExceptionHandling(); // Place the nuget config after all the middleware, this wil make it so all other error handeling is ignored and all errors are handled by the APM-globalMiddleware, if you want to use the APM-globalMiddleware in conjunction with other error handling middleware, place the APM-globalMiddleware before the other middleware.
appsettings.json
"ApplicationInsights": {
"ConnectionString": "<Placeholder>" //this can be empty, APM wil handle this internally if empty.
},
"ErrorHandling": {
"Enabled": true, // this is an optional field that can be used to enable or disable the APM-globalMiddleware, if not set, it will default to true.
"ServiceName": "<Service-placeholder>",
"ApiKey": "<Api-Placeholder>", // you get this from the APM backend deployment API-key
"ErrorUrl": "<Error-Placeholder>", // url/api/Errorreceive
"LogsUrl": "<Logs-Placeholder>", // url/api/ErrorReceive/logs
"UseAzureApplicationInsights": true, // this currently does nothing, but is reserved for future use
"CatchHttpErrors": false
}
Azure Functions Example
var builder = FunctionsApplication.CreateBuilder(args);
builder.ConfigureFunctionsWebApplication();
string aiConnectionString = builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"];
Log.Logger = new LoggerConfiguration()
.APMLLoggerEnricher(aiConnectionString)
.CreateLogger();
try
{
builder.Services.AddGlobalExceptionHandlingForFunctions(builder.Configuration);
builder.UseMiddleware<FunctionExceptionHandler>();
builder.Services.AddSerilog(Log.Logger);
builder.Build().Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}
local.settings.json
"Values": {
"Enabled": true, // this is an optional field that can be used to enable or disable the APM-globalMiddleware, if not set, it will default to true.
"APPLICATIONINSIGHTS_CONNECTION_STRING": "<Placeholder>",
"ErrorHandling:ServiceName": "<Service-placeholder>",
"ErrorHandling:ApiKey": "<Api-Placeholder>", // you get this from the APM backend deployment API-key
"ErrorHandling:ErrorUrl": "<Error-Placeholder>", // url/api/Errorreceive
"ErrorHandling:LogsUrl": "<Logs-Placeholder>", // url/api/ErrorReceive/logs
"ErrorHandling:UseAzureApplicationInsights": "true", // this currently does nothing, but is reserved for future use
"ErrorHandling:CatchHttpErrors": "false" // this does nothing for Azure functions
}
Hearthbeat Endpoint
APM-globalMiddleware includes a built-in heartbeat endpoint that can be used to monitor the health of your application.
The endpoint is available at /api/heartbeat and returns a simple JSON response indicating the status of the application.
ASP.NET Core Example
app.UseApmHeartbeat();
Or
app.UseApmHeartbeat("/health"); // this supports a custom endpoint
Metrics Integration
THIS IS CURRENTLY NOT IMPLEMENTED IN DE APM SO I SUGGEST TURNING THIS OFF OTHERWISE IT IS JUST A WASTE OF RESOURCES.
APM-globalMiddleware provides automatic collection and forwarding of custom metrics. This feature integrates seamlessly with your existing telemetry and logging infrastructure, allowing you to monitor application performance with minimal setup.
Initialization
To enable metrics collection, add the following line to your Program.cs or during service registration:
builder.Services.AddApmMetrics(builder.Configuration);
Configuration
"ErrorHandling": {
"MetricsUrl": "<Metrics-Placeholder>"
}
| 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 is compatible. 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. |
-
net10.0
- Microsoft.ApplicationInsights (>= 3.0.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 3.0.0)
- Microsoft.ApplicationInsights.WorkerService (>= 3.0.0)
- Microsoft.AspNetCore.Http (>= 2.3.9)
- Microsoft.AspNetCore.OpenApi (>= 10.0.5)
- Microsoft.Azure.Functions.Worker (>= 2.51.0)
- Serilog (>= 4.3.1)
- Serilog.Sinks.ApplicationInsights (>= 5.0.0)
- Serilog.Sinks.Http (>= 9.2.1)
-
net8.0
- Microsoft.ApplicationInsights (>= 3.0.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 3.0.0)
- Microsoft.ApplicationInsights.WorkerService (>= 3.0.0)
- Microsoft.AspNetCore.Http (>= 2.3.9)
- Microsoft.AspNetCore.OpenApi (>= 8.0.11)
- Microsoft.Azure.Functions.Worker (>= 2.51.0)
- Serilog (>= 4.3.1)
- Serilog.Sinks.ApplicationInsights (>= 5.0.0)
- Serilog.Sinks.Http (>= 9.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.5.6 | 306 | 5/8/2026 | |
| 1.5.5 | 125 | 4/24/2026 | |
| 1.5.4 | 131 | 4/24/2026 | |
| 1.5.1 | 133 | 4/23/2026 | |
| 1.5.0 | 139 | 4/23/2026 | |
| 1.4.2 | 142 | 4/21/2026 | |
| 1.4.1 | 166 | 4/7/2026 | |
| 1.4.0 | 144 | 4/3/2026 | |
| 1.3.0 | 161 | 3/26/2026 | |
| 1.2.5 | 193 | 3/25/2026 | |
| 1.2.4 | 153 | 3/25/2026 | |
| 1.2.3 | 143 | 3/24/2026 | |
| 1.2.2 | 134 | 3/24/2026 | |
| 1.2.1 | 134 | 3/24/2026 | |
| 1.2.0 | 144 | 3/24/2026 |