/// <summary> /// Write a metric sample /// </summary> private void WriteMetric() { EventMetricSample sample = Metric.CreateSample(); var elapsed = Timer.Elapsed; sample.SetValue(DurationCaption, elapsed); sample.Write(); if (WarningTimeSpan.HasValue && WarningTimeSpan.Value > TimeSpan.Zero && WarningTimeSpan.Value < elapsed) { var threshold = WarningTimeSpan.Value.TotalSeconds; var caption = _logCategory + " exceeds " + Math.Round(threshold, MaxDecimalDigits) + " seconds"; var description = "Elapsed time = " + Math.Round(elapsed.TotalSeconds, MaxDecimalDigits) + " seconds"; Log.Warning(null, _logCategory, caption, description); } }