public void ConfigureMetrics() { Logger.Info("Setting up Metrics"); var connectionString = ConfigurationManager.ConnectionStrings["Metric"]; if (connectionString == null) { throw new ArgumentException("No metrics connection string found"); } var data = connectionString.ConnectionString.Split(';'); var url = data.FirstOrDefault(x => x.StartsWith("Url", StringComparison.CurrentCultureIgnoreCase)); if (url == null) { throw new ArgumentException("No URL parameter in metrics connection string"); } Guid stashId; var stashIdStr = data.FirstOrDefault(x => x.StartsWith("StashId=", StringComparison.CurrentCultureIgnoreCase)); if (stashIdStr.IsNullOrEmpty() || !Guid.TryParse(stashIdStr.Substring(8), out stashId)) { throw new ArgumentException("No StashId parameter in metrics connection string"); } var stash = data.FirstOrDefault(x => x.StartsWith("Stash=", StringComparison.CurrentCultureIgnoreCase)); if (stash.IsNullOrEmpty()) { throw new ArgumentException("No Stash parameter in metrics connection string"); } var secret = data.FirstOrDefault(x => x.StartsWith("Secret=", StringComparison.CurrentCultureIgnoreCase)); if (secret.IsNullOrEmpty()) { throw new ArgumentException("No Secret parameter in metrics connection string"); } var @event = data.FirstOrDefault(x => x.StartsWith("Event=", StringComparison.CurrentCultureIgnoreCase)); if (string.IsNullOrEmpty(@event)) { throw new ArgumentException("No Event parameter in metrics connection string"); } url = url.Substring(4); stash = stash.Substring(6); secret = secret.Substring(7); @event = @event.Substring(6); var service = new Library.Demo.Demo(); ThreadPool.QueueUserWorkItem((_) => { service.Init(url, stashId, secret, stash, "Performance Counters").Wait(); }); //Metric.Config // .WithAppCounters() // .WithDemo(service, @event, TimeSpan.FromSeconds(30)); }
public IDemo ConfigureDemo() { var connectionString = ConfigurationManager.ConnectionStrings["Demo"]; var service = new Library.Demo.Demo(); var data = connectionString.ConnectionString.Split(';'); var url = data.FirstOrDefault(x => x.StartsWith("Url", StringComparison.CurrentCultureIgnoreCase)); if (url == null) { throw new ArgumentException("No URL parameter in pulse connection string"); } Guid stashId; var stashIdStr = data.FirstOrDefault(x => x.StartsWith("StashId=", StringComparison.CurrentCultureIgnoreCase)); if (stashIdStr.IsNullOrEmpty() || !Guid.TryParse(stashIdStr.Substring(8), out stashId)) { throw new ArgumentException("No StashId parameter in pulse connection string"); } var stash = data.FirstOrDefault(x => x.StartsWith("Stash=", StringComparison.CurrentCultureIgnoreCase)); if (stash.IsNullOrEmpty()) { throw new ArgumentException("No Stash parameter in pulse connection string"); } var secret = data.FirstOrDefault(x => x.StartsWith("Secret=", StringComparison.CurrentCultureIgnoreCase)); if (secret.IsNullOrEmpty()) { throw new ArgumentException("No Secret parameter in pulse connection string"); } url = url.Substring(4); stash = stash.Substring(6); secret = secret.Substring(7); ThreadPool.QueueUserWorkItem((_) => { service.Init(url, stashId, secret, stash, "Servicestack").Wait(); }); return(service); }