From e46b76d9b3d52b207ccf7749e89f06bfca08646f Mon Sep 17 00:00:00 2001 From: Ben Christensen Date: Fri, 30 Nov 2012 12:06:02 -0800 Subject: [PATCH] Simplified access to HystrixCommandMetrics Instead of requiring all access to go "over the top" via Servo or some other published mechanism allow simpler direct access to the metrics object. --- .../com/netflix/hystrix/HystrixCommandMetrics.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java index 8ff982c9a..1d4310f2c 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommandMetrics.java @@ -47,7 +47,7 @@ public class HystrixCommandMetrics { private static final ConcurrentHashMap metrics = new ConcurrentHashMap(); /** - * Get the {@link HystrixCommandMetrics} instance for a given {@link HystrixCommandKey}. + * Get or create the {@link HystrixCommandMetrics} instance for a given {@link HystrixCommandKey}. *

* This is thread-safe and ensures only 1 {@link HystrixCommandMetrics} per {@link HystrixCommandKey}. * @@ -82,6 +82,17 @@ public static HystrixCommandMetrics getInstance(HystrixCommandKey key, HystrixCo } } + /** + * Get the {@link HystrixCommandMetrics} instance for a given {@link HystrixCommandKey} or null if one does not exist. + * + * @param key + * {@link HystrixCommandKey} of {@link HystrixCommand} instance requesting the {@link HystrixCommandMetrics} + * @return {@link HystrixCommandMetrics} + */ + public static HystrixCommandMetrics getInstance(HystrixCommandKey key) { + return metrics.get(key.name()); + } + private final HystrixCommandProperties properties; private final HystrixRollingNumber counter; private final HystrixRollingPercentile percentileExecution;