forked from micrometer-metrics/micrometer
-
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.
Use direct counter/timer instrumentationfor hystrix
- Loading branch information
1 parent
3af71a2
commit f1ef7cf
Showing
6 changed files
with
186 additions
and
29 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...core/src/main/java/io/micrometer/core/instrument/binder/hystrix/HystrixMetricsBinder.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,30 @@ | ||
package io.micrometer.core.instrument.binder.hystrix; | ||
|
||
import com.netflix.hystrix.strategy.HystrixPlugins; | ||
import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy; | ||
import com.netflix.hystrix.strategy.eventnotifier.HystrixEventNotifier; | ||
import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; | ||
import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.micrometer.core.instrument.binder.MeterBinder; | ||
|
||
public class HystrixMetricsBinder implements MeterBinder { | ||
|
||
@Override | ||
public void bindTo(MeterRegistry registry) { | ||
// Keeps references of existing Hystrix plugins. | ||
HystrixEventNotifier eventNotifier = HystrixPlugins.getInstance().getEventNotifier(); | ||
HystrixPropertiesStrategy propertiesStrategy = HystrixPlugins.getInstance().getPropertiesStrategy(); | ||
HystrixCommandExecutionHook commandExecutionHook = HystrixPlugins.getInstance().getCommandExecutionHook(); | ||
HystrixConcurrencyStrategy concurrencyStrategy = HystrixPlugins.getInstance().getConcurrencyStrategy(); | ||
|
||
HystrixPlugins.reset(); | ||
|
||
// Registers existing plugins except the new MicroMeter Strategy plugin. | ||
HystrixPlugins.getInstance().registerMetricsPublisher(new MicrometerMetricsPublisher(registry)); | ||
HystrixPlugins.getInstance().registerConcurrencyStrategy(concurrencyStrategy); | ||
HystrixPlugins.getInstance().registerEventNotifier(eventNotifier); | ||
HystrixPlugins.getInstance().registerPropertiesStrategy(propertiesStrategy); | ||
HystrixPlugins.getInstance().registerCommandExecutionHook(commandExecutionHook); | ||
} | ||
} |
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
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
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
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
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