Watchlog.Metric 1.0.0

dotnet add package Watchlog.Metric --version 1.0.0
                    
NuGet\Install-Package Watchlog.Metric -Version 1.0.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="Watchlog.Metric" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Watchlog.Metric" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Watchlog.Metric" />
                    
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 Watchlog.Metric --version 1.0.0
                    
#r "nuget: Watchlog.Metric, 1.0.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.
#:package Watchlog.Metric@1.0.0
                    
#: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=Watchlog.Metric&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Watchlog.Metric&version=1.0.0
                    
Install as a Cake Tool

Watchlog.Metric (.NET Client)

🔗 Website: https://watchlog.io

Watchlog.Metric is a lightweight and non-blocking .NET client for sending custom metrics to your Watchlog server.

📦 Installation

Install the package via NuGet:

dotnet add package Watchlog.Metric

🚀 Quick Start

1. Import the namespace

using WatchlogMetric;

2. Create an instance of the Watchlog client

var watchlog = new WatchlogClient(); // No configuration needed

3. Send metrics

watchlog.Increment("user_login", 1);
watchlog.Decrement("cart_items", 2);
watchlog.Gauge("active_users", 120);
watchlog.Percentage("disk_usage", 73.5);
watchlog.SystemByte("memory_usage", 1048576);

All operations are asynchronous, non-blocking, and fail-safe — they never throw exceptions or print logs.


🐳 Docker Setup

When running your .NET app in Docker, you can specify the agent URL explicitly:

using WatchlogMetric;

// Create client with explicit agent URL for Docker
var watchlog = new WatchlogClient("http://watchlog-agent:3774");

watchlog.Increment("user_login", 1);

Docker Compose Example:

version: '3.8'

services:
  watchlog-agent:
    image: watchlog/agent:latest
    container_name: watchlog-agent
    ports:
      - "3774:3774"
    environment:
      - WATCHLOG_APIKEY=your-api-key
      - WATCHLOG_SERVER=https://log.watchlog.ir
    networks:
      - app-network

  dotnet-app:
    build: .
    container_name: dotnet-app
    ports:
      - "5000:5000"
    depends_on:
      - watchlog-agent
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

Docker Run Example:

# 1. Create network
docker network create app-network

# 2. Run Watchlog Agent
docker run -d \
  --name watchlog-agent \
  --network app-network \
  -p 3774:3774 \
  -e WATCHLOG_APIKEY="your-api-key" \
  -e WATCHLOG_SERVER="https://log.watchlog.ir" \
  watchlog/agent:latest

# 3. Run .NET app (make sure your code uses new WatchlogClient("http://watchlog-agent:3774"))
docker run -d \
  --name dotnet-app \
  --network app-network \
  -p 5000:5000 \
  my-dotnet-app

🔍 Environment Detection

The package automatically detects the runtime environment:

  • Local / non-K8s: http://127.0.0.1:3774
  • Kubernetes: http://watchlog-node-agent.monitoring.svc.cluster.local:3774

Manual Override: You can override the endpoint by passing agentUrl parameter to the constructor:

var watchlog = new WatchlogClient("http://watchlog-agent:3774"); // Custom agent URL

Important Notes:

  • When using Docker, use the container name as the hostname (e.g., watchlog-agent)
  • Both containers must be on the same Docker network
  • The agent must be running before your app starts
  • If agentUrl is not provided, auto-detection will be used (local or Kubernetes)

🛡️ Features

  • ✔️ Fully async-safe using Task.Run
  • ✔️ No logs, no exceptions
  • ✔️ Tiny footprint, pure .NET
  • ✔️ Works in ASP.NET Core, background services, or console apps

💡 Example: ASP.NET Core Integration

public class HomeController : Controller
{
    private readonly WatchlogClient _watchlog = new WatchlogClient();

    public IActionResult Index()
    {
        _watchlog.Increment("homepage_visits");
        return View();
    }
}

📄 License

MIT License

Product 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.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

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.0.0 173 11/22/2025
0.1.5 186 7/15/2025
0.1.4 117 7/5/2025
0.1.3 185 7/2/2025
0.1.2 193 5/21/2025
0.1.1 175 5/21/2025