CK.Monitoring.Metrics 0.3.3

dotnet add package CK.Monitoring.Metrics --version 0.3.3
                    
NuGet\Install-Package CK.Monitoring.Metrics -Version 0.3.3
                    
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="CK.Monitoring.Metrics" Version="0.3.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CK.Monitoring.Metrics" Version="0.3.3" />
                    
Directory.Packages.props
<PackageReference Include="CK.Monitoring.Metrics" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CK.Monitoring.Metrics --version 0.3.3
                    
#r "nuget: CK.Monitoring.Metrics, 0.3.3"
                    
#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.
#:package CK.Monitoring.Metrics@0.3.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CK.Monitoring.Metrics&version=0.3.3
                    
Install as a Cake Addin
#tool nuget:?package=CK.Monitoring.Metrics&version=0.3.3
                    
Install as a Cake Tool

CK.Monitoring.Metrics

Integrates CK.Metrics with CK.Monitoring by providing a GrandOutputHandler that writes metrics to a high-performance FasterLog.

Important: This package does not work on its own. The MetricsLogHandler requires a FasterLog instance to be injected at runtime. Use CK.AppIdentity.Monitoring.Metrics which provides MetricsFeatureDriver that manages the FasterLog lifecycle and injects it into the handler automatically.

Overview

This package provides:

  • MetricsLogHandler: A sealed IGrandOutputHandler that receives metrics from the GrandOutput pipeline and writes them to FasterLog
  • MetricsLogDispatcher: A parser for metrics log entries that dispatches to typed callbacks

The handler acts as a producer only - it writes metrics entries to FasterLog but does not consume them. Consumers are implemented separately (see CK.AppIdentity.Monitoring.Metrics).

Configuration

Add the handler to GrandOutput configuration:

{
  "CK-Monitoring": {
    "GrandOutput": {
      "Handlers": {
        "MetricsLogHandler, CK.Monitoring.Metrics": {
          "CommitRate": 1
        }
      }
    }
  }
}

Or simply enable with defaults:

{
  "CK-Monitoring": {
    "GrandOutput": {
      "Handlers": {
        "MetricsLogHandler, CK.Monitoring.Metrics": true
      }
    }
  }
}

Configuration Options

Property Type Default Description
CommitRate int 1 Multiplier of GrandOutput.TimerDuration (default 500ms) between FasterLog commits. A value of 1 commits every 500ms, 2 every 1 second, etc.

How It Works

  1. The handler receives log entries tagged with DotNetMetrics.MetricsTag from the GrandOutput pipeline
  2. Each entry is written to FasterLog with a timestamp prefix (8 bytes DateTime binary + ASCII text)
  3. FasterLog provides durability and supports multiple named consumers via persisted iterators

FasterLog Injection

The handler does not create or own the FasterLog instance. Instead, the FasterLog must be injected at runtime by calling MetricsLogHandler.SetFasterLog(FasterLog). Without this injection, the handler silently ignores all metrics entries.

Recommended approach: Use CK.AppIdentity.Monitoring.Metrics which provides MetricsFeatureDriver. This feature driver:

  1. Creates and manages the FasterLog instance
  2. Automatically injects it into the handler via SetMetricsFasterLogAction (a GrandOutputHandlersAction)
  3. Handles consumer registration and log truncation
  4. Cleans up orphaned consumers on shutdown

This design allows:

  • The handler to be configured via standard GrandOutput configuration
  • The FasterLog lifecycle to be managed externally (by AppIdentity or custom code)
  • Multiple consumers to share the same FasterLog instance

Entry Format

Each FasterLog entry contains:

  • 8 bytes: DateTime as binary (via DateTime.ToBinary())
  • Remaining bytes: ASCII-encoded metrics text

The text format follows the CK.Metrics log format for meters, instruments, and measurements.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CK.Monitoring.Metrics:

Package Downloads
CK.AppIdentity.Monitoring.Metrics

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.3 156 1/26/2026
0.3.2 150 1/26/2026
0.3.1 154 1/25/2026
0.3.0 154 1/24/2026
0.2.0 228 11/14/2025
0.1.1 118 9/27/2025
0.1.0 186 9/11/2025