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

Fixing https://github.com/Netflix/Hystrix/issues/1508 #1513

Merged
Merged
Show file tree
Hide file tree
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 @@ -273,7 +273,7 @@ public HystrixRollingNumberEvent call() {
}
});
// the rolling number of MaxConcurrentExecutionCount. Can be used to determine saturation
safelyCreateRollingCountForEvent("rollingMaxConcurentExecutionCount", new Func0<HystrixRollingNumberEvent>() {
safelyCreateRollingCountForEvent("rollingMaxConcurrentExecutionCount", new Func0<HystrixRollingNumberEvent>() {
@Override
public HystrixRollingNumberEvent call() {
return HystrixRollingNumberEvent.COMMAND_MAX_ACTIVE;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.netflix.hystrix.contrib.codahalemetricspublisher;

import com.codahale.metrics.Gauge;
import com.codahale.metrics.MetricRegistry;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.strategy.HystrixPlugins;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.Map;

public class HystrixCodaHaleMetricsPublisherCommandTest {
private final MetricRegistry metricRegistry = new MetricRegistry();

@Before
public void setup() {
HystrixPlugins.getInstance().registerMetricsPublisher(new HystrixCodaHaleMetricsPublisher(metricRegistry));
}

@After
public void teardown() {
HystrixPlugins.reset();
}

@Test
public void commandMaxActiveGauge() {
final HystrixCommandKey hystrixCommandKey = HystrixCommandKey.Factory.asKey("test");
final HystrixCommandGroupKey hystrixCommandGroupKey = HystrixCommandGroupKey.Factory.asKey("test");

new HystrixCommand<Void>(HystrixCommand.Setter
.withGroupKey(hystrixCommandGroupKey)
.andCommandKey(hystrixCommandKey)) {
@Override
protected Void run() throws Exception {
return null;
}
}.execute();

for (Map.Entry<String, Gauge> entry : metricRegistry.getGauges().entrySet()) {
entry.getValue().getValue();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public enum HystrixEventType {
EXCEPTION_THROWN(false),
RESPONSE_FROM_CACHE(true),
CANCELLED(true),
COLLAPSED(false);
COLLAPSED(false),
COMMAND_MAX_ACTIVE(false);

private final boolean isTerminal;

Expand Down Expand Up @@ -72,6 +73,7 @@ public static HystrixEventType from(HystrixRollingNumberEvent event) {
case RESPONSE_FROM_CACHE: return RESPONSE_FROM_CACHE;
case COLLAPSED: return COLLAPSED;
case BAD_REQUEST: return BAD_REQUEST;
case COMMAND_MAX_ACTIVE: return COMMAND_MAX_ACTIVE;
default:
throw new RuntimeException("Not an event that can be converted to HystrixEventType : " + event);
}
Expand Down