Пример #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);
        }
Пример #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));
        }
Пример #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));
        }
Пример #4
0
 static string GetMetricsListenerUrlPrefix(MetricsListenerConfig listenerConfig)
 => string.Format(CultureInfo.InvariantCulture, MetricsUrlPrefixFormat, listenerConfig.Host, listenerConfig.Port, listenerConfig.Suffix.Trim('/', ' '));
Пример #5
0
 public MetricsConfig(bool enabled, MetricsListenerConfig listenerConfig)
 {
     this.Enabled        = enabled;
     this.ListenerConfig = listenerConfig;
 }
Пример #6
0
 public MetricsConfig(IConfiguration config, bool enabledDefault = true)
 {
     this.Enabled        = config.GetValue("MetricsEnabled", enabledDefault);
     this.ListenerConfig = MetricsListenerConfig.Create(config);
 }