/// <summary> /// Constructor /// </summary> /// <param name="registry">Collector registry </param> /// <param name="options">Http server configuration options</param> public MetricServer(ICollectorRegistry registry, MetricServerOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (options.Port == 0) { throw new ArgumentException("Port should be specified"); } if (string.IsNullOrEmpty(options.MapPath) || !options.MapPath.StartsWith("/")) { throw new ArgumentException($"mapPath '{options.MapPath}' should start with '/'"); } _registry = registry ?? Metrics.DefaultCollectorRegistry; _options = options; }
/// <summary> /// Constructor /// </summary> /// <param name="registry">Collector registry </param> /// <param name="options">Http server configuration options</param> public MetricServer(ICollectorRegistry registry, MetricServerOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (options.Port == 0) { throw new ArgumentException("Port should be specified"); } if (string.IsNullOrEmpty(options.MapPath) || !options.MapPath.StartsWith("/")) { throw new ArgumentException($"mapPath '{options.MapPath}' should start with '/'"); } _registry = registry ?? Metrics.DefaultCollectorRegistry; _mapPath = options.MapPath.EndsWith("/") ? options.MapPath : options.MapPath + "/"; _httpListener.Prefixes.Add($"http{(options.UseHttps ? "s" : "")}://{options.Host}:{options.Port}/"); }