Faactory.Channels.Prometheus 0.10.0

dotnet add package Faactory.Channels.Prometheus --version 0.10.0
NuGet\Install-Package Faactory.Channels.Prometheus -Version 0.10.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Faactory.Channels.Prometheus" Version="0.10.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Faactory.Channels.Prometheus --version 0.10.0
#r "nuget: Faactory.Channels.Prometheus, 0.10.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Faactory.Channels.Prometheus as a Cake Addin
#addin nuget:?package=Faactory.Channels.Prometheus&version=0.10.0

// Install Faactory.Channels.Prometheus as a Cake Tool
#tool nuget:?package=Faactory.Channels.Prometheus&version=0.10.0

Prometheus Metrics

Extends Channels by providing Prometheus metrics.

The exported metrics are:

  • channels_active_total: Total number of active channels.
  • channels_bytes_received_total: Total number of bytes received.
  • channels_bytes_sent_total: Total number of bytes sent.

The project makes use of prometheus-net.

Usage

Install the package from NuGet

dotnet add package Faactory.Channels.Prometheus

To calculate the metrics, you just need to register the metrics middleware. This can be applied to either a service or a client channel builder.

IChannelBuilder channel = ...;

channel.UsePrometheusMetrics();

To export the metrics, the easiest way is to install prometheus-net.AspNetCore package and register the pre-built middleware. If no other HTTP functionality is required, this is a good option.

IServiceCollection services = ...;

services.AddMetricServer( options =>
{
    options.Port = 8081;
} );

You can find a more detailed sample project under the example folder. There are other ways to export the metrics, which can be found in the prometheus-net documentation.

Labels

By default, metrics are created just with the channelId label, which contains the channel identifier. However, it is possible to extend this and add more labels to the metrics.

To add more labels, you can add items to the channel's data dictionary. The middleware will automatically add all items with the prefix prometheus.label. to the metrics.

public class SampleIdentityHandler : ChannelHandler<IdentityInformation>
{
    public override Task ExecuteAsync( IChannelContext context, IdentityInformation data )
    {
        // ...

        /*
        This adds an `uuid` label to the metrics. The label will be included in all metrics.
        */
        context.Channel.Data["prometheus.label.uuid"] = data.UUId;

        return Task.CompletedTask;
    }
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.10.0 96 4/9/2024
0.9.0 101 1/30/2024
0.8.3 202 11/8/2023
0.8.0 118 10/20/2023
0.7.1 126 6/14/2023
0.7.0-preview-1 91 6/14/2023