forked from Netflix/Hystrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Netflix#1513 from chrisgray/codahale_metrics_comma…
…nd_max_active Fixing Netflix#1508
- Loading branch information
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters