public void LibratoTest() { string url = SensitiveSettings.SettingsManager.Settings["librato.URL"]; string token = SensitiveSettings.SettingsManager.Settings["librato.Token"]; string username = SensitiveSettings.SettingsManager.Settings["librato.Email"]; var metric = new Metric() { MetricType = MetricType.Gauge, Name = "UnitTest1", Value = new Random().NextDouble() }; bool wasSuccess = false; var store = new LibratoMetricsProvider(url, username, token, false); store.Store(metric, (r) => wasSuccess = r.Success); Assert.IsTrue(wasSuccess); }
public void LibratoTest2() { string url = SensitiveSettings.SettingsManager.Settings["Librato.URL"]; string token = SensitiveSettings.SettingsManager.Settings["Librato.Token"]; string username = SensitiveSettings.SettingsManager.Settings["Librato.Email"]; var rnd = new Random(); var metrics = new Metric[]{ new Metric() { MetricType = MetricType.Gauge, Name = "UnitTest2", Value = rnd.NextDouble() }, new Metric() { MetricType = MetricType.Gauge, Name = "UnitTest3", Value = rnd.NextDouble() }, new Metric() { MetricType = MetricType.Counter,Name = "UnitTestCounter1",Value = (int)(100 * rnd.NextDouble()) }, new Metric() { MetricType = MetricType.Counter,Name = "UnitTestCounter2",Value = (int)(100 * rnd.NextDouble()) } }; bool wasSuccess = false; var store = new LibratoMetricsProvider(url, username, token, false); store.Store(metrics, (r) => wasSuccess = r.Success); Assert.IsTrue(wasSuccess); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { _stopwatch.Stop(); string controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; string action = filterContext.ActionDescriptor.ActionName; var elapsed = _stopwatch.ElapsedMilliseconds; Dictionary<string,string> values = new Dictionary<string,string>(){ {"Time", _startTime.ToString("yyyy-MM-ddTHH:mm:ssZ")}, {"Controller", controller}, {"Action", action}, {"Elapsed", elapsed.ToString()} }; Logger.Log(values, null); var metrics = new Metric []{ new Metric(){ MetricType=MetricType.Counter, Name=String.Format("Hit.{0}.{1}", controller, action), Value=1 }, new Metric(){ MetricType=MetricType.Gauge, Name=String.Format("Elapsed.{0}.{1}", controller, action), Value=elapsed } }; MetricStore.Store(metrics); }
public static void Store(Metric metric) { GetDefaultLogger().Metrics.Store(metric, null); }
public void Store(Metric metric, Action<Communications.Result> callback) { SendMessage(new Metric[] { metric }, callback); }
public void Store(Metric metric, Action<Communications.Result> callback) { if (callback != null) callback(new Communications.Result { Success = true, RawContent = "{ success: true; }" }); }