public void Configure() { var url = GetSettingProperty("url"); if (string.IsNullOrEmpty(url)) { IsEnabled = false; return; } var env = GetSettingProperty("environment"); if(string.IsNullOrEmpty(env)) { IsEnabled = false; return; } var host = GetSettingProperty("host"); if(string.IsNullOrEmpty(host)) { host = Environment.MachineName; } var key = string.Concat(DEFAULT_PREFIX, env, ".", host, "."); var metricsConfig = new MetricsConfig { StatsdServerName = url, Prefix = key }; Metrics.Configure(metricsConfig); }
public StatsDOutput(TimberWinR.Manager manager, Parser.StatsDOutputParameters parameters, CancellationToken cancelToken) : base(cancelToken, "StatsD") { _params = parameters; _manager = manager; _port = parameters.Port; _host = parameters.Host; _interval = parameters.Interval; _flushSize = parameters.FlushSize; _idleFlushTimeSeconds = parameters.IdleFlushTimeInSeconds; _maxQueueSize = parameters.MaxQueueSize; _queueOverflowDiscardOldest = parameters.QueueOverflowDiscardOldest; _numThreads = parameters.NumThreads; _jsonQueue = new List<JObject>(); var metricsConfig = new MetricsConfig { StatsdServerName = _host, Prefix = parameters.Namespace, }; StatsdClient.Metrics.Configure(metricsConfig); for (int i = 0; i < _numThreads; i++) { Task.Factory.StartNew(StatsDSender, cancelToken, TaskCreationOptions.LongRunning, TaskScheduler.Current); } }
public void SetUpUdpListenerAndStatsd() { udpListener = new UdpListener(serverName, serverPort); var metricsConfig = new MetricsConfig { StatsdServerName = serverName }; StatsdClient.Metrics.Configure(metricsConfig); udp = new StatsdUDP(serverName, serverPort); statsd = new Statsd(udp); }
public void default_port_is_8125() { var metricsConfig = new MetricsConfig { StatsdServerName = "127.0.0.1" }; StatsdClient.Metrics.Configure(metricsConfig); testReceive("127.0.0.1", 8125, "test", "test:1|c"); }
public void setting_prefix() { var metricsConfig = new MetricsConfig { StatsdServerName = "127.0.0.1", Prefix = "prefix" }; StatsdClient.Metrics.Configure(metricsConfig); testReceive("127.0.0.1", 8125, "test", "prefix.test:1|c"); }
public void setting_port() { var metricsConfig = new MetricsConfig { StatsdServerName = "127.0.0.1", StatsdPort = 8126 }; StatsdClient.Metrics.Configure(metricsConfig); testReceive("127.0.0.1", 8126, "test", "test:1|c"); }
public void StartUdpListenerThread() { _defaultMetricsConfig = new MetricsConfig { StatsdServerName = _localhostAddress, StatsdServerPort = _randomUnusedLocalPort }; _listenThread = new Thread(_udpListener.Listen); _listenThread.Start(); }
private static void ConfigureStatsd(string statsdServerName, int statsdServerPort, string appEnvironment, string dataCenterRegion, string serviceType) { var prefix = GetPrefix(appEnvironment, dataCenterRegion, serviceType); var metricsConfig = new MetricsConfig { StatsdServerName = statsdServerName, StatsdServerPort = statsdServerPort, Prefix = prefix }; Metrics.Configure(metricsConfig); }
public void StartUdpListenerThread() { _defaultMetricsConfig = new MetricsConfig { StatsdServerName = _localhostAddress, StatsdServerPort = _randomUnusedLocalPort, Sender = new ThreadSafeConsumerProducerSender(new ThreadSafeConsumerProducerSender.Configuration() { MaxSendDelayMS = 100 }) }; _listenThread = new Thread(_udpListener.Listen); _listenThread.Start(); }
public StatsdInterceptor() { _lock = new object(); _callCounter = new Dictionary<string, int>(); _exceptionCounter = new Dictionary<string, int>(); var metricsConfig = new MetricsConfig { StatsdServerName = ConfigurationManager.AppSettings["StatsdServerName"], Prefix = ConfigurationManager.AppSettings["StatsdServerName"], StatsdServerPort = int.Parse(ConfigurationManager.AppSettings["StatsdServerPort"]) }; Metrics.Configure(metricsConfig); }
/// <summary> /// The application start event. /// </summary> protected void Application_Start() { RegisterRoutes(RouteTable.Routes); InitProfilerSettings(); // this is only done for testing purposes so we don't check in the db to source control // parameter table is only used in this project for sample queries // yes, it is ugly, and do not do this unless you know for sure that the second Store in the MultiStorageProvider is of this type ((SqliteMiniProfilerStorage)((MultiStorageProvider)MiniProfiler.Settings.Storage).Stores[1]).RecreateDatabase("create table RouteHits(RouteName,HitCount,unique(RouteName))"); var entityFrameworkDataPath = HttpContext.Current.Server.MapPath("~/App_Data/SampleWeb.EFCodeFirst.EFContext.sdf"); if (File.Exists(entityFrameworkDataPath)) { File.Delete(entityFrameworkDataPath); } // Setup profiler for Controllers via a Global ActionFilter GlobalFilters.Filters.Add(new ProfilingActionFilter()); // initialize automatic view profiling var copy = ViewEngines.Engines.ToList(); ViewEngines.Engines.Clear(); foreach (var item in copy) { ViewEngines.Engines.Add(new ProfilingViewEngine(item)); } MiniProfilerEF6.Initialize(); var metricsConfig = new MetricsConfig { StatsdServerName = "localhost", StatsdServerPort = 8125, Prefix = "MiniProfiler" }; Metrics.Configure(metricsConfig); }
public void throw_exception_when_no_hostname_provided() { var metricsConfig = new MetricsConfig {}; Assert.Throws<ArgumentNullException>(() => StatsdClient.Metrics.Configure(metricsConfig)); }