public void Many_meric_and_dynamic_metric() { var evt = new LogEventInfo("Test", "App") { Metrics = { ["M1"] = 1, ["M2"] = 2 }, DynamicMetrics = { ["D1"] = DynamicMetric.From(() => 1), ["D2"] = DynamicMetric.From(() => 2) } }; var expected = new Dictionary <string, double> { ["App.M1"] = 1, ["App.M2"] = 2, ["App.D1"] = 1, ["App.D2"] = 2 }; Assert.That(evt.GetQualifiedMetrics(), Is.EquivalentTo(expected)); }
public void Event_and_metric_has_same_Prefix() { var evt = new LogEventInfo("Test", "App") { Metrics = { ["App.M1"] = 1 } }; var expected = new Dictionary <string, double> { ["App.M1"] = 1 }; Assert.That(evt.GetQualifiedMetrics(), Is.EquivalentTo(expected)); }
public void One_dynamic_has_Prefix() { var evt = new LogEventInfo("Test", "App") { DynamicMetrics = { ["M1"] = DynamicMetric.From(() => 1) } }; var expected = new Dictionary <string, double> { ["App.M1"] = 1 }; Assert.That(evt.GetQualifiedMetrics(), Is.EquivalentTo(expected)); }
public void One_no_Prefix() { var evt = new LogEventInfo("Test") { Metrics = { ["M1"] = 1 } }; var expected = new Dictionary <string, double> { ["M1"] = 1 }; Assert.That(evt.GetQualifiedMetrics(), Is.EquivalentTo(expected)); }
public string Serialize(LogEventInfo source) { if (!source.HasMetric && !source.HasProperty) { return(String.Format(FieldTemplate, EventFieldName, source.FullName)); } var properties = source.GetQualifiedProperties(); var metrics = source.GetQualifiedMetrics(); int elementCount = GetPropertyAndMetricCount(properties, metrics); var sb = new StringBuilder(1 + elementCount * 50); sb.AppendFormat(FieldTemplate, EventFieldName, source.FullName); WriteCollection(properties, sb); WriteCollection(metrics, sb); return(sb.ToString()); }
public void None() { var evt = new LogEventInfo("Test"); Assert.That(evt.GetQualifiedMetrics(), Is.Null); }