Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

nazarovsa/Metron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metron

Build Status nuget version Nuget

Metron is simple metrics library.

Get started

  1. Create model which inherits from Model. Model contains Guid Id and DateTimeOffset CreatedAt properties which initialized at parameterless constructor.
public sealed class UserLoggedIn : Model 
{
  public string Username { get; set; }
}
  1. Initialize repository which implements IModelRepository
public sealed class InMemoryRepository : IModelRepository<UserLoggedIn> 
{
  private readonly List<UserLoggedIn> _items;
  
  public InMemoryRepository()
  {
    _items = new List<UserLoggedIn>();
  }
  
  public Task Add(UserLoggedIn model, CancellationToken cancellationToken = default)
  {
    _items.Add(model);
    return Task.CompletedTask;
  }
    
  public Task<IReadOnlyCollection<UserLoggedIn>> Get(CancellationToken cancellationToken = default)
    => Task.FromResult<IReadOnlyCollection<UserLoggedIn>>(_items);
}
  1. Initialize Metron instance with created repository.
var repository = new InMemoryRepository();
var metron = new Metron(repository);
  1. Use metron instance to write and get metrics.
var item = new UserLoggedIn { Username = "root" };
await metron.Add(item);
var items = metron.Get(CancellationToken.None);

Metron.Extensions

nuget version Nuget

DI extensions for Metron.

Avaliable containers:

  • Autofac

Readme in progress

Metron.Repository

nuget version Nuget

Repositories for Metron.

Avaliable repositories:

  • MongoDb

Readme in progress

About

Simple metrics library

Resources

License

Stars

Watchers

Forks

Packages

No packages published