Search in sources :

Example 1 with MultipleAssignmentSubscription

use of rx.subscriptions.MultipleAssignmentSubscription in project Hystrix by Netflix.

the class HystrixMetricsStreamHandler method handleHystrixRequest.

private Observable<Void> handleHystrixRequest(final HttpServerResponse<O> response) {
    writeHeaders(response);
    final Subject<Void, Void> subject = PublishSubject.create();
    final MultipleAssignmentSubscription subscription = new MultipleAssignmentSubscription();
    Subscription actionSubscription = Observable.interval(interval, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {

        @Override
        public void call(Long tick) {
            if (!response.getChannel().isOpen()) {
                subscription.unsubscribe();
                return;
            }
            try {
                for (HystrixCommandMetrics commandMetrics : HystrixCommandMetrics.getInstances()) {
                    writeMetric(SerialHystrixDashboardData.toJsonString(commandMetrics), response);
                }
                for (HystrixThreadPoolMetrics threadPoolMetrics : HystrixThreadPoolMetrics.getInstances()) {
                    writeMetric(SerialHystrixDashboardData.toJsonString(threadPoolMetrics), response);
                }
                for (HystrixCollapserMetrics collapserMetrics : HystrixCollapserMetrics.getInstances()) {
                    writeMetric(SerialHystrixDashboardData.toJsonString(collapserMetrics), response);
                }
            } catch (Exception e) {
                subject.onError(e);
            }
        }
    });
    subscription.set(actionSubscription);
    return subject;
}
Also used : HystrixThreadPoolMetrics(com.netflix.hystrix.HystrixThreadPoolMetrics) MultipleAssignmentSubscription(rx.subscriptions.MultipleAssignmentSubscription) Subscription(rx.Subscription) HystrixCommandMetrics(com.netflix.hystrix.HystrixCommandMetrics) HystrixCollapserMetrics(com.netflix.hystrix.HystrixCollapserMetrics) MultipleAssignmentSubscription(rx.subscriptions.MultipleAssignmentSubscription)

Aggregations

HystrixCollapserMetrics (com.netflix.hystrix.HystrixCollapserMetrics)1 HystrixCommandMetrics (com.netflix.hystrix.HystrixCommandMetrics)1 HystrixThreadPoolMetrics (com.netflix.hystrix.HystrixThreadPoolMetrics)1 Subscription (rx.Subscription)1 MultipleAssignmentSubscription (rx.subscriptions.MultipleAssignmentSubscription)1