or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

base-sse-servlet.mdconfiguration-streaming.mdindex.mdlegacy-metrics-polling.mdmetrics-streaming.mdrequest-events-streaming.mdutilization-streaming.md
tile.json

tessl/maven-com-netflix-hystrix--hystrix-metrics-event-stream

A Netflix Hystrix module that exposes circuit breaker and thread pool metrics in Server-Sent Events format for real-time monitoring and dashboard integration

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/com.netflix.hystrix/hystrix-metrics-event-stream@1.5.x

To install, run

npx @tessl/cli install tessl/maven-com-netflix-hystrix--hystrix-metrics-event-stream@1.5.0

index.mddocs/

Hystrix Metrics Event Stream

Hystrix Metrics Event Stream is a Java library module within the Netflix Hystrix circuit breaker framework that provides real-time streaming of circuit breaker and thread pool metrics via Server-Sent Events (SSE). The module enables monitoring dashboards and applications to receive continuous metric updates including error rates, latency percentiles, circuit breaker states, and thread pool statistics.

Package Information

  • Package Name: hystrix-metrics-event-stream
  • Package Type: maven
  • Language: Java
  • Installation: Add to Maven dependencies:
    <dependency>
      <groupId>com.netflix.hystrix</groupId>
      <artifactId>hystrix-metrics-event-stream</artifactId>
      <version>1.5.18</version>
    </dependency>

Core Imports

// Primary streaming servlets
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import com.netflix.hystrix.contrib.requests.stream.HystrixRequestEventsSseServlet;
import com.netflix.hystrix.contrib.sample.stream.HystrixConfigSseServlet;
import com.netflix.hystrix.contrib.sample.stream.HystrixUtilizationSseServlet;
import com.netflix.hystrix.contrib.sample.stream.HystrixSampleSseServlet;

// Legacy polling (deprecated)
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsPoller;

// RxJava Observable types
import rx.Observable;

Basic Usage

The primary use case is to expose Hystrix metrics via HTTP Server-Sent Events:

<!-- Configure in web.xml -->
<servlet>
  <servlet-name>HystrixMetricsStreamServlet</servlet-name>
  <servlet-class>com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>HystrixMetricsStreamServlet</servlet-name>
  <url-pattern>/hystrix.stream</url-pattern>
</servlet-mapping>

Then access the stream:

curl http://hostname:port/appname/hystrix.stream

This produces continuous JSON events like:

data: {
  "type": "HystrixCommand",
  "name": "PlaylistGet",
  "group": "PlaylistGet",
  "currentTime": 1355239617628,
  "isCircuitBreakerOpen": false,
  "errorPercentage": 0,
  "errorCount": 0,
  "requestCount": 121,
  "latencyExecute_mean": 13,
  "latencyTotal_mean": 15
}

Architecture

The library is organized around several key components:

  • Servlet Layer: HTTP servlets that implement Server-Sent Events streaming protocol
  • Poller Layer: Background polling mechanisms for gathering metrics (deprecated)
  • Stream Processing: RxJava-based reactive streams for real-time data processing
  • JSON Serialization: Jackson-based JSON encoding of metric data
  • Connection Management: Configurable concurrent connection limits and throttling

Capabilities

Metrics Streaming

Primary servlet for streaming Hystrix command and thread pool metrics in text/event-stream format.

public class HystrixMetricsStreamServlet extends HystrixSampleSseServlet {
    public HystrixMetricsStreamServlet();
    HystrixMetricsStreamServlet(Observable<HystrixDashboardStream.DashboardData> sampleStream, int pausePollerThreadDelayInMs);
}

Metrics Streaming

Base SSE Servlet Framework

Abstract base class providing Server-Sent Events functionality for all streaming servlets.

public abstract class HystrixSampleSseServlet extends HttpServlet {
    protected HystrixSampleSseServlet(Observable<String> sampleStream);
    protected HystrixSampleSseServlet(Observable<String> sampleStream, int pausePollerThreadDelayInMs);
    
    // Abstract methods for connection management
    protected abstract int getMaxNumberConcurrentConnectionsAllowed();
    protected abstract int getNumberCurrentConnections();
    protected abstract int incrementAndGetCurrentConcurrentConnections();
    protected abstract void decrementCurrentConcurrentConnections();
    
    // Lifecycle methods
    public static void shutdown();
    public void init() throws ServletException;
    public void destroy();
}

Base SSE Framework

Request Events Streaming

Servlet that streams individual Hystrix request events as they occur.

public class HystrixRequestEventsSseServlet extends HystrixSampleSseServlet {
    public HystrixRequestEventsSseServlet();
    HystrixRequestEventsSseServlet(Observable<HystrixRequestEvents> sampleStream, int pausePollerThreadDelayInMs);
}

Request Events Streaming

Configuration Streaming

Servlet that streams Hystrix configuration information.

public class HystrixConfigSseServlet extends HystrixSampleSseServlet {
    public HystrixConfigSseServlet();
    HystrixConfigSseServlet(Observable<HystrixConfiguration> sampleStream, int pausePollerThreadDelayInMs);
}

Configuration Streaming

Utilization Streaming

Servlet that streams current Hystrix command and thread pool utilization metrics.

public class HystrixUtilizationSseServlet extends HystrixSampleSseServlet {
    public HystrixUtilizationSseServlet();
    HystrixUtilizationSseServlet(Observable<HystrixUtilization> sampleStream, int pausePollerThreadDelayInMs);
}

Utilization Streaming

Legacy Metrics Polling (Deprecated)

Polling-based metrics collection system (deprecated since 1.5.4).

@Deprecated
public class HystrixMetricsPoller {
    public HystrixMetricsPoller(MetricsAsJsonPollerListener listener, int delay);
    public synchronized void start();
    public synchronized void pause();
    public synchronized void shutdown();
    public boolean isRunning();
    
    public static interface MetricsAsJsonPollerListener {
        public void handleJsonMetric(String json);
    }
}

Legacy Metrics Polling

Configuration

Connection Limits

All servlets support configurable maximum concurrent connections:

// System property configuration (default: 5)
hystrix.config.stream.maxConcurrentConnections=10

Threading

  • Default pause delay: 500ms between polling cycles
  • Uses RxJava IO scheduler for non-blocking stream processing
  • Atomic connection counting for thread safety

Types

// Core Data Classes
public class HystrixDashboardStream.DashboardData {
    // Contains dashboard metrics for commands and thread pools
}

public interface HystrixRequestEvents {
    // Contains detailed request execution information including events and latencies
}

public interface HystrixConfiguration {
    // Contains complete configuration for commands, thread pools, and collapsers
    Map<HystrixCommandKey, HystrixCommandConfiguration> getCommandConfig();
    Map<HystrixThreadPoolKey, HystrixThreadPoolConfiguration> getThreadPoolConfig();
    Map<HystrixCollapserKey, HystrixCollapserConfiguration> getCollapserConfig();
}

public interface HystrixUtilization {
    // Contains current utilization metrics for commands and thread pools
    Map<HystrixCommandKey, HystrixCommandUtilization> getCommandUtilizationMap();
    Map<HystrixThreadPoolKey, HystrixThreadPoolUtilization> getThreadPoolUtilizationMap();
}

// RxJava Observable Type
public class Observable<T> {
    // Reactive stream for asynchronous data processing
}

// Configuration Properties
public class DynamicIntProperty {
    int get();
}

Error Handling

  • HTTP 503 responses when max concurrent connections exceeded
  • Graceful handling of client disconnections
  • Automatic cleanup of resources when servlets are destroyed
  • Version mismatch protection for deprecated metrics fields