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

configuration-streaming.mddocs/

Configuration Streaming

Servlet that streams Hystrix configuration information including command properties, thread pool settings, and collapser configuration in real-time.

Capabilities

HystrixConfigSseServlet

Servlet that streams Hystrix configuration data in text/event-stream format.

/**
 * Streams Hystrix config in text/event-stream format
 * Provides real-time configuration information for commands, thread pools, and collapsers
 */
public class HystrixConfigSseServlet extends HystrixSampleSseServlet {
    
    /**
     * Default constructor using HystrixConfigurationStream and default delay
     */
    public HystrixConfigSseServlet();
    
    /**
     * Package-private constructor for testing with custom stream and delay
     * @param sampleStream Observable stream of configuration data
     * @param pausePollerThreadDelayInMs Delay between polling cycles in milliseconds
     */
    HystrixConfigSseServlet(Observable<HystrixConfiguration> sampleStream, int pausePollerThreadDelayInMs);
    
    /**
     * Returns maximum number of concurrent connections allowed
     * @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();
}

HystrixConfigurationJsonStream (Deprecated)

Legacy utility for converting configuration objects to JSON format.

/**
 * Links HystrixConfigurationStream and JSON encoding
 * @deprecated Since 1.5.4 - prefer mapping serialization on HystrixConfigurationStream.observe()
 */
@Deprecated
public class HystrixConfigurationJsonStream {
    
    /**
     * Default constructor using default configuration stream
     */
    public HystrixConfigurationJsonStream();
    
    /**
     * Constructor with custom stream generator
     * @param streamGenerator Function to generate configuration observable
     */
    public HystrixConfigurationJsonStream(Func1<Integer, Observable<HystrixConfiguration>> streamGenerator);
    
    /**
     * Convert configuration object to JSON string
     * @param config Configuration object to convert
     * @return JSON string representation
     * @throws IOException if JSON generation fails
     */
    public static String convertToString(HystrixConfiguration config) throws IOException;
    
    /**
     * @deprecated Use HystrixConfigurationStream.observe() instead
     */
    @Deprecated
    public Observable<HystrixConfiguration> observe(int delay);
    
    /**
     * @deprecated Use HystrixConfigurationStream.observe() and convertToString() instead
     */
    @Deprecated
    public Observable<String> observeJson(int delay);
}

Web.xml Configuration:

<servlet>
  <description></description>
  <display-name>HystrixConfigSseServlet</display-name>
  <servlet-name>HystrixConfigSseServlet</servlet-name>
  <servlet-class>com.netflix.hystrix.contrib.sample.stream.HystrixConfigSseServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>HystrixConfigSseServlet</servlet-name>
  <url-pattern>/hystrix/config.stream</url-pattern>
</servlet-mapping>

Usage Examples:

// Deploy servlet via web.xml configuration
// Access configuration stream
curl http://localhost:8080/app/hystrix/config.stream

// Using deprecated JSON stream API
HystrixConfigurationJsonStream stream = new HystrixConfigurationJsonStream();
stream.observe(1000).subscribe(config -> {
    String json = HystrixConfigurationJsonStream.convertToString(config);
    System.out.println("Config: " + json);
});

Data Format

The servlet outputs comprehensive configuration information in JSON format:

Configuration Structure

data: {
  "type": "HystrixConfig",
  "commands": {
    "GetUser": {
      "threadPoolKey": "GetUser",
      "groupKey": "UserService",
      "execution": {
        "isolationStrategy": "THREAD",
        "threadPoolKeyOverride": null,
        "requestCacheEnabled": true,
        "requestLogEnabled": true,
        "timeoutEnabled": true,
        "fallbackEnabled": true,
        "timeoutInMilliseconds": 1000,
        "semaphoreSize": 10,
        "fallbackSemaphoreSize": 10,
        "threadInterruptOnTimeout": true
      },
      "metrics": {
        "healthBucketSizeInMs": 500,
        "percentileBucketSizeInMilliseconds": 60000,
        "percentileBucketCount": 6,
        "percentileEnabled": true,
        "counterBucketSizeInMilliseconds": 10000,
        "counterBucketCount": 10
      },
      "circuitBreaker": {
        "enabled": true,
        "isForcedOpen": false,
        "isForcedClosed": false,
        "requestVolumeThreshold": 20,
        "errorPercentageThreshold": 50,
        "sleepInMilliseconds": 5000
      }
    }
  },
  "threadpools": {
    "GetUser": {
      "coreSize": 10,
      "maximumSize": 10,
      "actualMaximumSize": 10,
      "maxQueueSize": -1,
      "queueRejectionThreshold": 5,
      "keepAliveTimeInMinutes": 1,
      "allowMaximumSizeToDivergeFromCoreSize": false,
      "counterBucketSizeInMilliseconds": 10000,
      "counterBucketCount": 10
    }
  },
  "collapsers": {
    "UserDataCollapser": {
      "maxRequestsInBatch": 100,
      "timerDelayInMilliseconds": 10,
      "requestCacheEnabled": true,
      "metrics": {
        "percentileBucketSizeInMilliseconds": 60000,
        "percentileBucketCount": 6,
        "percentileEnabled": true,
        "counterBucketSizeInMilliseconds": 10000,
        "counterBucketCount": 10
      }
    }
  }
}

Command Configuration Properties

Execution Configuration:

  • isolationStrategy - THREAD or SEMAPHORE
  • threadPoolKeyOverride - Custom thread pool key
  • requestCacheEnabled - Whether request caching is enabled
  • requestLogEnabled - Whether request logging is enabled
  • timeoutEnabled - Whether execution timeout is enabled
  • fallbackEnabled - Whether fallback is enabled
  • timeoutInMilliseconds - Execution timeout in milliseconds
  • semaphoreSize - Semaphore max concurrent requests
  • fallbackSemaphoreSize - Fallback semaphore max concurrent requests
  • threadInterruptOnTimeout - Whether to interrupt thread on timeout

Metrics Configuration:

  • healthBucketSizeInMs - Health snapshot bucket size
  • percentileBucketSizeInMilliseconds - Percentile bucket size
  • percentileBucketCount - Number of percentile buckets
  • percentileEnabled - Whether percentile tracking is enabled
  • counterBucketSizeInMilliseconds - Counter bucket size
  • counterBucketCount - Number of counter buckets

Circuit Breaker Configuration:

  • enabled - Whether circuit breaker is enabled
  • isForcedOpen - Whether circuit breaker is forced open
  • isForcedClosed - Whether circuit breaker is forced closed (Note: Source has bug referencing isForceOpen() instead)
  • requestVolumeThreshold - Minimum requests before circuit breaker trips
  • errorPercentageThreshold - Error percentage threshold for tripping
  • sleepInMilliseconds - Sleep window when circuit is open

Thread Pool Configuration Properties

  • coreSize - Core thread pool size
  • maximumSize - Maximum thread pool size
  • actualMaximumSize - Actual maximum size in use
  • maxQueueSize - Maximum queue size (-1 for unbounded)
  • queueRejectionThreshold - Queue size rejection threshold
  • keepAliveTimeInMinutes - Thread keep-alive time
  • allowMaximumSizeToDivergeFromCoreSize - Whether max size can exceed core size
  • counterBucketSizeInMilliseconds - Metrics counter bucket size
  • counterBucketCount - Number of metrics counter buckets

Collapser Configuration Properties

  • maxRequestsInBatch - Maximum requests per batch
  • timerDelayInMilliseconds - Delay before executing batch
  • requestCacheEnabled - Whether request caching is enabled
  • metrics - Metrics configuration (similar to command metrics)

Migration from Deprecated API

// Old approach (deprecated)
HystrixConfigurationJsonStream jsonStream = new HystrixConfigurationJsonStream();
jsonStream.observeJson(1000).subscribe(json -> {
    // process json
});

// New approach (recommended)
HystrixConfigurationStream.getInstance()
    .observe()
    .map(SerialHystrixConfiguration::toJsonString)
    .subscribe(json -> {
        // process json
    });

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