Permillity 1.0.2

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

Permillity

Permillity is a lightweight endpoint performance tracker designed to monitor each request in your application. It is simple to integrate, making it ideal for small to medium-sized projects or applications. With support for in-memory, SQL Server, MySQL and SQLite backends, Permillity helps you gain insights into your application's performance effortlessly.

Overview

Permillity tracks and logs requests in your application, offering a dashboard for visualizing performance data and plain statistics for custom usage. The library is lightweight, flexible, and easy to configure, ensuring minimal overhead while providing meaningful insights.

Key Features:

  • Lightweight: Optimized for small and medium-sized projects.
  • Database Options: Supports in-memory, SQL Server, MySQL and SQLite.
  • Customizable: Includes options to ignore specific endpoints or batch process data.
  • Dashboard and Data: View a pre-built dashboard or access raw performance data.

Installation

Permillity is available as a NuGet package. You can install it using the NuGet Package Console window:

PM> Install-Package Permillity

Usage

To register Permillity add the following lines in Program.cs class:

// Register Permillity services
builder.Services.AddPermillity();
// Add Permillity middleware
app.AddPermillityMiddleware();

You can customize Permillity during servise registration. AddPermillity() method accepts options builder as a parameter.

Configuration options:

  • UseInMemory(): Permillity will use in-memory storage. This option is default.
  • UseSqlServer(conString): Permillity will use ms sql server as a storage. Requires connection string as a parameter.
  • UseMySql(conString): Permillity will use my sql as a storage. Requires connection string as a parameter.
  • UseSqlite(conString): Permillity will use sqlite as a storage. Requires connection string as a parameter.
  • UseLogger(): Permillity will use logger if available to log errors. Default is false.
  • SetBatchSize(50): Permillity will sync data with storage each N requests. Default is 50. For real-time sync use 0.
  • SetIgnoreEndpoints(["WeatherForecast"]): Permillity will ignore listed endpoints.

Example registering Permillity to MS SQL Server with logger, batch size and list of endpoints to ignore:

var conString = "ConnectionString";

builder.Services.AddPermillity(x =>
{
    x.UseSqlServer(conString); //use sql server 
    x.UseLogger(); //use logger
    x.SetBatchSize(0); //set batch size to 0 for real time tracking
    x.SetIgnoreEndpoints(["api/sign-up", "api/employees"]); //ignore tracking of sign-up and employees enpoints
});

You can also ignore specific endpoints by adding a [PermillityAvoid] attribute:

[PermillityAvoid]
[HttpGet()]
public IActionResult TestEndpoint()
{
    return Ok("This endpoint will not be logged.");
}

Dashboard

To render the Permillity dashboard in an endpoint, inject IPermillityService and use the GetDashboardAsync method:

[HttpGet("dashboard")]
public async Task<IActionResult> GetDashboard([FromServices] IPermillityService permillityService)
{
    var html = await permillityService.GetDashboardAsync();
    return Content(html, "text/html");
}

For raw statistics, use the GetStatisticsDataAsync method:

[HttpGet()]
public async Task<IActionResult> GetStatistics([FromServices] IPermillityService permillityService)
{
    var data = await permillityService.GetStatisticsDataAsync();
    return Ok(data);
}

Technical info

When using sql server, mysql or sqlite databases Permillity will create one table for tracking data: ApiStats. Statistics are kept by endpoint by week and year. If you want to clear statistics when it become burdensome just delete data from the table. There is possibility that some request will not be logged (for example, if app crashes or is shut down before current batch is synced with database.) Statistics numbers should be used as reference only.

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.

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.2 123 12/1/2024
1.0.1 123 11/22/2024
1.0.0 118 11/21/2024

Added sqlite support