public void CanCleanExpiredMetrics() { var files = new List <string>(new[] { "file1.txt", "file2.txt", "file3.txt" }); using (var env = new StorageEnvironment(StorageEnvironmentOptions.CreateMemoryOnly())) { var envWithType = new StorageEnvironmentWithType("test", StorageEnvironmentWithType.StorageEnvironmentType.Documents, env); foreach (var fileName in files) { for (var i = 0; i < 2 * 256; i++) { var now = DateTime.UtcNow.AddHours(-7); var meterIoRate = env.Options.IoMetrics.MeterIoRate(fileName, IoMetrics.MeterType.JournalWrite, i + 1); var durationMeasurement = new IoMeterBuffer.DurationMeasurement(meterIoRate.Parent, IoMetrics.MeterType.JournalWrite, i + 1, 0, null) { Start = now, End = now.AddMilliseconds(2) }; meterIoRate.Parent.Mark(ref durationMeasurement); } } CheckMetricFiles(env, files, checkForNull: false); IEnumerable <StorageEnvironmentWithType> environments = new[] { envWithType }; IoMetricsUtil.CleanIoMetrics(environments, DateTime.UtcNow.Ticks); CheckMetricFiles(env, files, checkForNull: true); } }
public async Task IoMetrics() { using (ServerStore.ContextPool.AllocateOperationContext(out JsonOperationContext context)) await using (var writer = new AsyncBlittableJsonTextWriter(context, ResponseBodyStream())) { var result = IoMetricsUtil.GetIoMetricsResponse(GetSystemEnvironment(ServerStore), null); context.Write(writer, result.ToJson()); } }
public async Task IoMetrics() { using (ContextPool.AllocateOperationContext(out JsonOperationContext context)) await using (var writer = new AsyncBlittableJsonTextWriter(context, ResponseBodyStream())) { var result = IoMetricsUtil.GetIoMetricsResponse(Database.GetAllStoragesEnvironment(), Database.GetAllPerformanceMetrics()); context.Write(writer, result.ToJson()); } }