Exemple #1
0
        /// <summary>
        /// Create HTTP endpoint where metrics will be available in various formats:
        /// GET / => visualization application
        /// GET /json => metrics serialized as JSON
        /// GET /text => metrics in human readable text format
        /// </summary>
        /// <param name="httpUriPrefix">prefix where to start HTTP endpoint</param>
        /// <param name="filter">Only report metrics that match the filter.</param>
        /// <param name="maxRetries">maximum number of attempts to start the http listener. Note the retry time between attempts is dependent on this value</param>
        /// <returns>Chain-able configuration object.</returns>
        public MetricsConfig WithHttpEndpoint(string httpUriPrefix, MetricsFilter filter = null, int maxRetries = 3)
        {
            if (this.isDisabled)
            {
                return(this);
            }

            if (this.httpEndpoints.ContainsKey(httpUriPrefix))
            {
                log.WarnFormat("Http uri prefix {0} already registered. Ignoring...", httpUriPrefix);
                return(this);
            }

            var endpoint = MetricsHttpListener.StartHttpListenerAsync(httpUriPrefix, this.context.DataProvider.WithFilter(filter),
                                                                      this.healthStatus, this.httpEndpointCancellation.Token, maxRetries);

            this.httpEndpoints.Add(httpUriPrefix, endpoint);

            return(this);
        }
Exemple #2
0
        /// <summary>
        /// Create HTTP endpoint where metrics will be available in various formats:
        /// GET / => visualization application
        /// GET /json => metrics serialized as JSON
        /// GET /text => metrics in human readable text format
        /// </summary>
        /// <param name="httpUriPrefix">prefix where to start HTTP endpoint</param>
        /// <param name="reportsConfig">Endpoint reports configuration</param>
        /// <param name="filter">Only report metrics that match the filter.</param>
        /// <param name="maxRetries">maximum number of attempts to start the http listener. Note the retry time between attempts is dependent on this value</param>
        /// <returns>Chain-able configuration object.</returns>
        public MetricsConfig WithHttpEndpoint(string httpUriPrefix, Action <MetricsEndpointReports> reportsConfig, MetricsFilter filter = null, int maxRetries = 3)
        {
            if (this.isDisabled)
            {
                return(this);
            }

            if (this.httpEndpoints.ContainsKey(httpUriPrefix))
            {
                throw new InvalidOperationException($"Http URI prefix {httpUriPrefix} already configured.");
            }

            var endpointReports = new MetricsEndpointReports(this.context.DataProvider.WithFilter(filter), this.healthStatus);

            reportsConfig(endpointReports);

            var endpoint = MetricsHttpListener.StartHttpListenerAsync(httpUriPrefix, endpointReports.Endpoints, this.httpEndpointCancellation.Token, maxRetries);

            this.httpEndpoints.Add(httpUriPrefix, endpoint);

            return(this);
        }
Exemple #3
0
        private static Task <MetricsHttpListener> StartListener(string endpoint)
        {
            var context = new TestContext();

            return(MetricsHttpListener.StartHttpListenerAsync(Endpoint(endpoint), context.DataProvider, () => new HealthStatus(), CancellationToken.None));
        }
Exemple #4
0
        private static Task <MetricsHttpListener> StartListener(string endpoint)
        {
            var context = new TestContext();

            return(MetricsHttpListener.StartHttpListenerAsync(Endpoint(endpoint), Enumerable.Empty <MetricsEndpoint>(), CancellationToken.None));
        }