Prometheus.EntityFramework 1.0.0

Prometheus EntityFramework Monitoring Middleware

Install-Package Prometheus.EntityFramework -Version 1.0.0
dotnet add package Prometheus.EntityFramework --version 1.0.0
<PackageReference Include="Prometheus.EntityFramework" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Prometheus.EntityFramework --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Prometheus Entity Framework

Why Just .NET Framework 4.6.1

Currently this package is only supported for .Net Framework 4.6.1 because of dependencies.

| Dependency | net40 | net461 | netcoreapp1.3 | netcoreapp2.2 |
| ---------- | ----- | ------ | ------------- | ------------- |
| EF Interceptions | TRUE | TRUE | FALSE | FALSE |
| Prometheus.Client | FALSE | TRUE | TRUE | TRUE |

Usage

  • Install and configure Prometheus.Client.Owin package.
  • Install this project package (Which is not available yet).
  • Create Interceptor options.
public class MyPrometheusInterceptorOptions : PrometheusInterceptorOptions
{
  public override bool ReaderNotLogged => true;

  public class MyPrometheusInterceptorOptions : PrometheusInterceptorOptions
  {
    public override void Executed<T>(DbCommand command,
      DbCommandInterceptionContext<T> interceptionContext,
      Stopwatch stopwatch,
      InterceptedMethod interceptedMethod)
    {
      var labels = new[] {"CommandText", "Database", "DataSource", "ExceptionOccured"};
      var values = new[] {command.CommandText, command.Connection.Database, command.Connection.DataSource, (interceptionContext.Exception != null).ToString() };
      Metrics.CreateGauge("LogName", "Log Help Text", labels)
        .Labels(values)
        .Set(stopwatch.ElapsedMilliseconds);
    }
  }
}
  • Create a DbConfiguration or update existing.
public class MyPrometheusDbConfiguration : DbConfiguration
{
  public MyPrometheusDbConfiguration()
  {
    AddInterceptor(new PrometheusDbCommandInterceptor(new MyPrometheusInterceptorOptions()));
  }
}
  • Use Configuration above DbContext
[DbConfigurationType(typeof(MyPrometheusDbConfiguration))]
public class MyDbContext : DbContext
{
  public MyDbContext(string name) : base(name) {}
  ...
}

Project Plan

  • [x] Support .NET Framework
  • [x] Support Customizable Metrics
  • [ ] Create Nuget package
  • [ ] Support .NET Core
  • [ ] Create Test Projects
  • [ ] Source Code Documentation

Prometheus Entity Framework

Why Just .NET Framework 4.6.1

Currently this package is only supported for .Net Framework 4.6.1 because of dependencies.

| Dependency | net40 | net461 | netcoreapp1.3 | netcoreapp2.2 |
| ---------- | ----- | ------ | ------------- | ------------- |
| EF Interceptions | TRUE | TRUE | FALSE | FALSE |
| Prometheus.Client | FALSE | TRUE | TRUE | TRUE |

Usage

  • Install and configure Prometheus.Client.Owin package.
  • Install this project package (Which is not available yet).
  • Create Interceptor options.
public class MyPrometheusInterceptorOptions : PrometheusInterceptorOptions
{
  public override bool ReaderNotLogged => true;

  public class MyPrometheusInterceptorOptions : PrometheusInterceptorOptions
  {
    public override void Executed<T>(DbCommand command,
      DbCommandInterceptionContext<T> interceptionContext,
      Stopwatch stopwatch,
      InterceptedMethod interceptedMethod)
    {
      var labels = new[] {"CommandText", "Database", "DataSource", "ExceptionOccured"};
      var values = new[] {command.CommandText, command.Connection.Database, command.Connection.DataSource, (interceptionContext.Exception != null).ToString() };
      Metrics.CreateGauge("LogName", "Log Help Text", labels)
        .Labels(values)
        .Set(stopwatch.ElapsedMilliseconds);
    }
  }
}
  • Create a DbConfiguration or update existing.
public class MyPrometheusDbConfiguration : DbConfiguration
{
  public MyPrometheusDbConfiguration()
  {
    AddInterceptor(new PrometheusDbCommandInterceptor(new MyPrometheusInterceptorOptions()));
  }
}
  • Use Configuration above DbContext
[DbConfigurationType(typeof(MyPrometheusDbConfiguration))]
public class MyDbContext : DbContext
{
  public MyDbContext(string name) : base(name) {}
  ...
}

Project Plan

  • [x] Support .NET Framework
  • [x] Support Customizable Metrics
  • [ ] Create Nuget package
  • [ ] Support .NET Core
  • [ ] Create Test Projects
  • [ ] Source Code Documentation

Release Notes

Initialize package.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0 75 5/30/2019