示例#1
0
        public HystrixMetricsStreamPublisher(HystrixDashboardStream stream, HystrixConnectionFactory factory, ILogger <HystrixMetricsStreamPublisher> logger, IDiscoveryClient discoveryClient = null)
        {
            this.discoveryClient = discoveryClient;
            this.logger          = logger;

            observable = stream.Observe().Map((data) => {
                return(Serialize.ToJsonList(data, this.discoveryClient));
            });

            this.factory = factory.ConnectionFactory as ConnectionFactory;

            Task.Factory.StartNew(() => { StartMetricsPublishing(); });
        }
示例#2
0
        public void Constructor_SetsupStream()
        {
            var stream  = HystrixDashboardStream.GetInstance();
            var factory = new HystrixConnectionFactory(new ConnectionFactory());
            var options = new OptionsWrapper <HystrixMetricsStreamOptions>()
            {
                Value = new HystrixMetricsStreamOptions()
            };
            var publisher = new RabbitMetricsStreamPublisher(options, stream, factory);

            Assert.NotNull(publisher.SampleSubscription);
            Assert.NotNull(publisher.Factory);
            publisher.SampleSubscription.Dispose();
        }
示例#3
0
        public HystrixMetricsStreamPublisher(IOptions <HystrixMetricsStreamOptions> options, HystrixDashboardStream stream, HystrixConnectionFactory factory, ILogger <HystrixMetricsStreamPublisher> logger = null, IDiscoveryClient discoveryClient = null)
        {
            this.discoveryClient = discoveryClient;
            this.logger          = logger;
            this.options         = options.Value;

            observable = stream.Observe().Map((data) => {
                return(Serialize.ToJsonList(data, this.discoveryClient));
            });

            this.factory = factory.ConnectionFactory as ConnectionFactory;
            SslOption sslOption = this.factory.Ssl;

            if (sslOption != null && sslOption.Enabled && !this.options.Validate_Certificates)
            {
                logger?.LogInformation("Hystrix Metrics disabling certificate validation");
                sslOption.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateChainErrors |
                                                   SslPolicyErrors.RemoteCertificateNameMismatch | SslPolicyErrors.RemoteCertificateNotAvailable;
            }

            StartMetricsPublishing();
        }
        public RabbitMetricsStreamPublisher(IOptions <HystrixMetricsStreamOptions> options, HystrixDashboardStream stream, HystrixConnectionFactory factory, ILogger <RabbitMetricsStreamPublisher> logger = null, IDiscoveryClient discoveryClient = null)
            : base(options, stream, logger, discoveryClient)
        {
            Factory = factory.ConnectionFactory as ConnectionFactory;
            var sslOption = Factory.Ssl;

            if (sslOption != null && sslOption.Enabled)
            {
                logger?.LogInformation("Hystrix Metrics using TLS");
                sslOption.Version = SslProtocols.Tls12 | SslProtocols.Tls13;
                if (!this.options.Validate_Certificates)
                {
                    logger?.LogInformation("Hystrix Metrics disabling certificate validation");
                    sslOption.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateChainErrors |
                                                       SslPolicyErrors.RemoteCertificateNameMismatch | SslPolicyErrors.RemoteCertificateNotAvailable;
                }
            }

            StartMetricsPublishing();
        }