AppMetrics.Grpc.AspNetCore
1.0.0
See the version list below for details.
dotnet add package AppMetrics.Grpc.AspNetCore --version 1.0.0
NuGet\Install-Package AppMetrics.Grpc.AspNetCore -Version 1.0.0
<PackageReference Include="AppMetrics.Grpc.AspNetCore" Version="1.0.0" />
paket add AppMetrics.Grpc.AspNetCore --version 1.0.0
#r "nuget: AppMetrics.Grpc.AspNetCore, 1.0.0"
// Install AppMetrics.Grpc.AspNetCore as a Cake Addin
#addin nuget:?package=AppMetrics.Grpc.AspNetCore&version=1.0.0
// Install AppMetrics.Grpc.AspNetCore as a Cake Tool
#tool nuget:?package=AppMetrics.Grpc.AspNetCore&version=1.0.0
AppMetrics.Grpc.AspNetCore
Provides an interceptor that can be used to track protobuf-net.Grpc.AspNetCore endpoint calls using App.Metrics.AspNetCore.Tracking middleware components.
A standalone MetricsServer
is provided to help expose the metrics on a separate port.
Usage
Add interceptor when registering code-first services:
using AppMetrics.Grpc.AspNetCore.Interceptors;
public void ConfigureServices(IServiceCollection services)
{
services.AddCodeFirstGrpc(config =>
{
config.ResponseCompressionLevel = System.IO.Compression.CompressionLevel.Optimal;
config.Interceptors.Add<MetricsInterceptor>();
});
}
To expose metrics on a different port using the MetricsServer
call AddMetricsServer
either on a IHostBuilder
or a IWebHostBuilder
and pass the same IMetricsRoot
instance used in the main host:
using AppMetrics.Grpc.AspNetCore.HostedServices;
using App.Metrics;
using App.Metrics.AspNetCore;
using App.Metrics.Formatters.Json;
using App.Metrics.Formatters.Prometheus;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using System.Linq;
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) {
var metrics = App.Metrics.AppMetrics.CreateDefaultBuilder()
.OutputMetrics.AsPrometheusPlainText()
.Build();
return Host.CreateDefaultBuilder(args)
.ConfigureMetrics(metrics)
.UseMetrics()
.AddMetricsServer(metrics, endpointsOptions =>
{
endpointsOptions.MetricsEndpointOutputFormatter = metrics.OutputMetricsFormatters.OfType<MetricsJsonOutputFormatter>().First();
endpointsOptions.MetricsTextEndpointOutputFormatter = metrics.OutputMetricsFormatters.OfType<MetricsPrometheusTextOutputFormatter>().First();
endpointsOptions.EnvironmentInfoEndpointEnabled = false;
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
Configuration
Optionally add the following configuration to your appsettings.json
"MetricsServerOptions": {
"EnvironmentInfoEndpoint": "/env",
"MetricsEndpoint": "/metrics",
"MetricsTextEndpoint": "/metrics-text",
"Port": 5501
}
By default the MetricsServer
will listen on port 5501
on all interfaces.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- App.Metrics.AspNetCore (>= 4.3.0)
- App.Metrics.Formatters.Prometheus (>= 4.3.0)
- Grpc.AspNetCore.Server (>= 2.43.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Options (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.