Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make queue size of MetricJsonListener configurable #1149

Merged
merged 3 commits into from
Mar 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class HystrixMetricsStreamServlet extends HttpServlet {
/* used to track number of connections and throttle */
private static AtomicInteger concurrentConnections = new AtomicInteger(0);
private static DynamicIntProperty maxConcurrentConnections = DynamicPropertyFactory.getInstance().getIntProperty("hystrix.stream.maxConcurrentConnections", 5);
private static DynamicIntProperty defaultMetricListenerQueueSize = DynamicPropertyFactory.getInstance().getIntProperty("hystrix.stream.defaultMetricListenerQueueSize", 1000);

private static volatile boolean isDestroyed = false;

Expand Down Expand Up @@ -133,7 +134,9 @@ private void handleRequest(HttpServletRequest request, HttpServletResponse respo
response.setHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
response.setHeader("Pragma", "no-cache");

MetricJsonListener jsonListener = new MetricJsonListener();
int queueSize = defaultMetricListenerQueueSize.get();

MetricJsonListener jsonListener = new MetricJsonListener(queueSize);
poller = new HystrixMetricsPoller(jsonListener, delay);
// start polling and it will write directly to the output stream
poller.start();
Expand Down Expand Up @@ -205,7 +208,11 @@ private static class MetricJsonListener implements HystrixMetricsPoller.MetricsA
* <p>
* This is a safety check against a runaway poller causing memory leaks.
*/
private final LinkedBlockingQueue<String> jsonMetrics = new LinkedBlockingQueue<String>(1000);
private LinkedBlockingQueue<String> jsonMetrics;

public MetricJsonListener(int queueSize) {
jsonMetrics = new LinkedBlockingQueue<String>(queueSize);
}

/**
* Store JSON messages in a queue.
Expand Down