This commit is contained in:
@@ -5,6 +5,7 @@ using System.Diagnostics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Util;
|
||||
using AyaNova.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +17,7 @@ namespace AyaNova.Biz
|
||||
internal static class CoreJobMetricsSnapshot
|
||||
{
|
||||
private static ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger("CoreJobMetricsSnapshot");
|
||||
private static TimeSpan tsDataRetention = new TimeSpan(396, 0, 0, 0, 0);//one year and one month approximately
|
||||
private static Process _process = Process.GetCurrentProcess();
|
||||
|
||||
private static TimeSpan _oldCPUTime = TimeSpan.Zero;
|
||||
@@ -34,7 +36,7 @@ namespace AyaNova.Biz
|
||||
public static async Task DoJobAsync(AyContext ct)
|
||||
{
|
||||
//https://github.com/sebastienros/memoryleak/blob/master/src/MemoryLeak/MemoryLeak/Controllers/DiagnosticsController.cs
|
||||
// //DATA TYPES .net to postgres map
|
||||
// //DATA TYPES .net to postgres map
|
||||
//http://www.npgsql.org/doc/types/basic.html
|
||||
|
||||
//Gather stats, output to database but only every minute or more
|
||||
@@ -190,10 +192,10 @@ from generate_series(1, 525600) s(i)
|
||||
// The number of generation 2 collections
|
||||
var Gen2 = GC.CollectionCount(2);//integer
|
||||
|
||||
var CPU=_cpu;// double precision
|
||||
var CPU = _cpu;// double precision
|
||||
|
||||
//write to db
|
||||
MetricMM mm = new MetricMM(Allocated,WorkingSet,PrivateBytes,Gen0,Gen1,Gen2,CPU);
|
||||
MetricMM mm = new MetricMM(Allocated, WorkingSet, PrivateBytes, Gen0, Gen1, Gen2, CPU);
|
||||
await ct.MetricMM.AddAsync(mm);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
@@ -243,7 +245,7 @@ from generate_series(1, 525600) s(i)
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
//ONCE A DAY SNAPS
|
||||
//ONCE A DAY SNAPS AND CLEANUP
|
||||
//
|
||||
if (DateUtil.IsAfterDuration(_lastSnapshot, ts24Hours))
|
||||
{
|
||||
@@ -260,7 +262,12 @@ from generate_series(1, 525600) s(i)
|
||||
// metrics.Measure.Gauge.SetValue(MetricsRegistry.FileCountGauge, mtag, UtilFilesInfo.FileCountWithChildren);
|
||||
// metrics.Measure.Gauge.SetValue(MetricsRegistry.FileSizeGauge, mtag, UtilFilesInfo.SizeWithChildren);
|
||||
|
||||
/////////////////////////////////
|
||||
//CLEAR OLD ENTRIES
|
||||
//
|
||||
|
||||
DateTime ClearAfter = DateTime.UtcNow - tsDataRetention;
|
||||
await ct.Database.ExecuteSqlInterpolatedAsync($"delete from ametricmm where t > {ClearAfter}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user