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(); }); }
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 void TestStreamHasData() { AtomicBoolean commandShowsUp = new AtomicBoolean(false); CountdownEvent latch = new CountdownEvent(1); int NUM = 10; for (int i = 0; i < 2; i++) { HystrixCommand <int> cmd = Command.From(groupKey, commandKey, HystrixEventType.SUCCESS, 50); cmd.Observe(); } stream.Observe().Take(NUM).Subscribe( (dashboardData) => { output.WriteLine(DateTime.Now.Ticks / 10000 + " : Received data with : " + dashboardData.commandMetrics.Count + " commands"); foreach (HystrixCommandMetrics metrics in dashboardData.commandMetrics) { if (metrics.CommandKey.Equals(commandKey)) { commandShowsUp.Value = true; } } }, (e) => { output.WriteLine(DateTime.Now.Ticks / 10000 + " : " + Thread.CurrentThread.ManagedThreadId + " OnError : " + e); }, () => { output.WriteLine(DateTime.Now.Ticks / 10000 + " : " + Thread.CurrentThread.ManagedThreadId + " OnCompleted"); latch.SignalEx(); }); Assert.True(latch.Wait(10000)); Assert.True(commandShowsUp.Value); }
public void TestStreamHasData() { var commandShowsUp = new AtomicBoolean(false); var latch = new CountdownEvent(1); var num = 10; for (var i = 0; i < 2; i++) { HystrixCommand <int> cmd = Command.From(GroupKey, CommandKey, HystrixEventType.SUCCESS, 50); cmd.Observe(); } stream.Observe().Take(num).Subscribe( (dashboardData) => { output.WriteLine(Time.CurrentTimeMillis + " : Received data with : " + dashboardData.CommandMetrics.Count + " commands"); foreach (var metrics in dashboardData.CommandMetrics) { if (metrics.CommandKey.Equals(CommandKey)) { commandShowsUp.Value = true; } } }, (e) => { output.WriteLine(Time.CurrentTimeMillis + " : " + Thread.CurrentThread.ManagedThreadId + " OnError : " + e); }, () => { output.WriteLine(Time.CurrentTimeMillis + " : " + Thread.CurrentThread.ManagedThreadId + " OnCompleted"); latch.SignalEx(); }); Assert.True(latch.Wait(10000), "CountdownEvent was not set!"); Assert.True(commandShowsUp.Value); }
public HystrixMetricsStreamController(HystrixDashboardStream stream) : this(stream.Observe()) { }