CtrlK
BlogDocsLog inGet started
Tessl Logo

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

Pending
Overview
Eval results
Files

metrics-streaming.mddocs/

Metrics Streaming

The primary servlet for streaming Hystrix command and thread pool metrics in text/event-stream format for real-time monitoring and dashboard integration.

Capabilities

HystrixMetricsStreamServlet

Main servlet that provides SSE streaming of Hystrix dashboard metrics including circuit breaker states, latency percentiles, and thread pool statistics.

/**
 * Streams Hystrix metrics in text/event-stream format.
 * Install by including hystrix-metrics-event-stream-*.jar in classpath
 * and configuring in web.xml with URL pattern /hystrix.stream
 */
public class HystrixMetricsStreamServlet extends HystrixSampleSseServlet {
    
    /**
     * Default constructor using HystrixDashboardStream and default delay
     */
    public HystrixMetricsStreamServlet();
    
    /**
     * Package-private constructor for testing with custom stream and delay
     * @param sampleStream Observable stream of dashboard data
     * @param pausePollerThreadDelayInMs Delay between polling cycles in milliseconds
     */
    HystrixMetricsStreamServlet(Observable<HystrixDashboardStream.DashboardData> sampleStream, int pausePollerThreadDelayInMs);
    
    /**
     * Returns maximum number of concurrent connections allowed (configurable via hystrix.config.stream.maxConcurrentConnections)
     * @return Maximum concurrent connections (default: 5)
     */
    protected int getMaxNumberConcurrentConnectionsAllowed();
    
    /**
     * Returns current number of active connections
     * @return Current connection count
     */
    protected int getNumberCurrentConnections();
    
    /**
     * Atomically increments and returns current concurrent connection count
     * @return New connection count after increment
     */
    protected int incrementAndGetCurrentConcurrentConnections();
    
    /**
     * Atomically decrements current concurrent connection count
     */
    protected void decrementCurrentConcurrentConnections();
}

Web.xml Configuration:

<servlet>
  <description></description>
  <display-name>HystrixMetricsStreamServlet</display-name>
  <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>

Usage Examples:

// Basic servlet deployment - just configure in web.xml
// No additional Java code required

// Testing servlet with curl
curl http://localhost:8080/app/hystrix.stream

// Custom configuration via system properties
System.setProperty("hystrix.config.stream.maxConcurrentConnections", "10");

Data Format

The servlet outputs JSON events in Server-Sent Events format:

HystrixCommand Metrics

data: {
  "type": "HystrixCommand",
  "name": "PlaylistGet",
  "group": "PlaylistGet", 
  "currentTime": 1355239617628,
  "isCircuitBreakerOpen": false,
  "errorPercentage": 0,
  "errorCount": 0,
  "requestCount": 121,
  "rollingCountSuccess": 121,
  "rollingCountFailure": 0,
  "rollingCountTimeout": 0,
  "rollingCountShortCircuited": 0,
  "rollingCountThreadPoolRejected": 0,
  "rollingCountSemaphoreRejected": 0,
  "currentConcurrentExecutionCount": 0,
  "latencyExecute_mean": 13,
  "latencyExecute": {
    "0": 3, "25": 6, "50": 8, "75": 14, "90": 26, "95": 37, "99": 75, "99.5": 92, "100": 252
  },
  "latencyTotal_mean": 15,
  "latencyTotal": {
    "0": 3, "25": 7, "50": 10, "75": 18, "90": 32, "95": 43, "99": 88, "99.5": 160, "100": 253
  },
  "propertyValue_circuitBreakerRequestVolumeThreshold": 20,
  "propertyValue_circuitBreakerSleepWindowInMilliseconds": 5000,
  "propertyValue_circuitBreakerErrorThresholdPercentage": 50,
  "propertyValue_executionIsolationStrategy": "THREAD",
  "propertyValue_executionIsolationThreadTimeoutInMilliseconds": 800,
  "reportingHosts": 1,
  "threadPool": "PlaylistGet"
}

HystrixThreadPool Metrics

data: {
  "type": "HystrixThreadPool",
  "name": "ABClient",
  "currentTime": 1355239617628,
  "currentActiveCount": 0,
  "currentCompletedTaskCount": 4459519,
  "currentCorePoolSize": 30,
  "currentLargestPoolSize": 30,
  "currentMaximumPoolSize": 30,
  "currentPoolSize": 30,
  "currentQueueSize": 0,
  "currentTaskCount": 4459519,
  "rollingMaxActiveThreads": 13,
  "rollingCountThreadsExecuted": 919,
  "propertyValue_queueSizeRejectionThreshold": 30,
  "propertyValue_metricsRollingStatisticalWindowInMilliseconds": 30000,
  "reportingHosts": 3
}

Configuration Properties

// System properties for configuration
public static final String MAX_CONCURRENT_CONNECTIONS_PROPERTY = "hystrix.config.stream.maxConcurrentConnections";
public static final int DEFAULT_MAX_CONCURRENT_CONNECTIONS = 5;

Error Handling

  • Returns HTTP 503 when maximum concurrent connections exceeded
  • Graceful handling of client disconnections via PrintWriter.checkError()
  • Automatic resource cleanup when servlet is destroyed
  • Thread-safe connection counting using AtomicInteger

Install with Tessl CLI

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

docs

base-sse-servlet.md

configuration-streaming.md

index.md

legacy-metrics-polling.md

metrics-streaming.md

request-events-streaming.md

utilization-streaming.md

tile.json