Exemple #1
0
        public MetricsConfig(IConfiguration config, bool enabledDefault = true)
        {
            this.Enabled         = config.GetValue("MetricsEnabled", enabledDefault);
            this.HistogramMaxAge = config.GetValue("MetricsHistogramMaxAge", TimeSpan.FromHours(1));

            this.ListenerConfig = MetricsListenerConfig.Create(config);
        }
Exemple #2
0
        public MetricsListener(MetricsListenerConfig listenerConfig, IMetricsProvider metricsProvider)
        {
            this.listenerConfig = Preconditions.CheckNotNull(listenerConfig, nameof(listenerConfig));
            string url = GetMetricsListenerUrlPrefix(listenerConfig);

            this.httpListener = new HttpListener();
            this.httpListener.Prefixes.Add(url);
            this.metricsProvider = Preconditions.CheckNotNull(metricsProvider, nameof(metricsProvider));
        }
Exemple #3
0
        public static MetricsConfig Create(IConfiguration config)
        {
            bool enabled = config.GetValue("enabled", false);
            MetricsListenerConfig listenerConfig = enabled
                ? MetricsListenerConfig.Create(config.GetSection("listener"))
                : new MetricsListenerConfig();

            return(new MetricsConfig(enabled, listenerConfig));
        }
Exemple #4
0
 static string GetMetricsListenerUrlPrefix(MetricsListenerConfig listenerConfig)
 => string.Format(CultureInfo.InvariantCulture, MetricsUrlPrefixFormat, listenerConfig.Host, listenerConfig.Port, listenerConfig.Suffix.Trim('/', ' '));
Exemple #5
0
 public MetricsConfig(bool enabled, MetricsListenerConfig listenerConfig)
 {
     this.Enabled        = enabled;
     this.ListenerConfig = listenerConfig;
 }
Exemple #6
0
 public MetricsConfig(IConfiguration config, bool enabledDefault = true)
 {
     this.Enabled        = config.GetValue("MetricsEnabled", enabledDefault);
     this.ListenerConfig = MetricsListenerConfig.Create(config);
 }