From 154867792b0041b013639efe849b87d63c0b28c3 Mon Sep 17 00:00:00 2001 From: Fredrik Kjellberg Date: Thu, 21 Nov 2013 21:17:47 +0100 Subject: [PATCH 1/2] Add module to publish metrics to Coda Hale Metrics --- .../README.md | 25 ++ .../build.gradle | 24 ++ .../HystrixCodaHaleMetricsPublisher.java | 48 +++ ...ystrixCodaHaleMetricsPublisherCommand.java | 320 ++++++++++++++++++ ...rixCodaHaleMetricsPublisherThreadPool.java | 149 ++++++++ settings.gradle | 1 + 6 files changed, 567 insertions(+) create mode 100644 hystrix-contrib/hystrix-codahale-metrics-publisher/README.md create mode 100644 hystrix-contrib/hystrix-codahale-metrics-publisher/build.gradle create mode 100644 hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisher.java create mode 100644 hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherCommand.java create mode 100644 hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherThreadPool.java diff --git a/hystrix-contrib/hystrix-codahale-metrics-publisher/README.md b/hystrix-contrib/hystrix-codahale-metrics-publisher/README.md new file mode 100644 index 000000000..62d360ae7 --- /dev/null +++ b/hystrix-contrib/hystrix-codahale-metrics-publisher/README.md @@ -0,0 +1,25 @@ +# hystrix-codahale-metrics-publisher + +This is an implementation of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/index.html?com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) that publishes metrics using [Coda Hale Metrics](http://metrics.codahale.com). + +See the [Metrics & Monitoring](https://github.com/Netflix/Hystrix/wiki/Metrics-and-Monitoring) Wiki for more information. + +# Binaries + +Binaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22hystrix-codahale-metrics-publisher%22). + +Example for Maven: + +```xml + + com.netflix.hystrix + hystrix-codahale-metrics-publisher + 1.1.2 + +``` + +and for Ivy: + +```xml + +``` \ No newline at end of file diff --git a/hystrix-contrib/hystrix-codahale-metrics-publisher/build.gradle b/hystrix-contrib/hystrix-codahale-metrics-publisher/build.gradle new file mode 100644 index 000000000..3f324a096 --- /dev/null +++ b/hystrix-contrib/hystrix-codahale-metrics-publisher/build.gradle @@ -0,0 +1,24 @@ +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'idea' + +dependencies { + compile project(':hystrix-core') + compile 'com.codahale.metrics:metrics-core:3.0.1' +} + +eclipse { + classpath { + // include 'provided' dependencies on the classpath + plusConfigurations += configurations.provided + downloadSources = true + downloadJavadoc = true + } +} + +idea { + module { + // include 'provided' dependencies on the classpath + scopes.COMPILE.plus += configurations.provided + } +} diff --git a/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisher.java b/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisher.java new file mode 100644 index 000000000..7b30d0eeb --- /dev/null +++ b/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisher.java @@ -0,0 +1,48 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.netflix.hystrix.contrib.codahalemetricspublisher; + +import com.codahale.metrics.MetricRegistry; +import com.netflix.hystrix.HystrixCircuitBreaker; +import com.netflix.hystrix.HystrixCommandGroupKey; +import com.netflix.hystrix.HystrixCommandKey; +import com.netflix.hystrix.HystrixCommandMetrics; +import com.netflix.hystrix.HystrixCommandProperties; +import com.netflix.hystrix.HystrixThreadPoolKey; +import com.netflix.hystrix.HystrixThreadPoolMetrics; +import com.netflix.hystrix.HystrixThreadPoolProperties; +import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisher; +import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherCommand; +import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherThreadPool; + +/** + * Coda Hale Metrics (https://github.com/codahale/metrics) implementation of {@link HystrixMetricsPublisher}. + */ +public class HystrixCodaHaleMetricsPublisher extends HystrixMetricsPublisher { + private final MetricRegistry metricRegistry; + + public HystrixCodaHaleMetricsPublisher(MetricRegistry metricRegistry) { + this.metricRegistry = metricRegistry; + } + + @Override + public HystrixMetricsPublisherCommand getMetricsPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) { + return new HystrixCodaHaleMetricsPublisherCommand(commandKey, commandGroupKey, metrics, circuitBreaker, properties, metricRegistry); + } + + @Override + public HystrixMetricsPublisherThreadPool getMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, HystrixThreadPoolProperties properties) { + return new HystrixCodaHaleMetricsPublisherThreadPool(threadPoolKey, metrics, properties, metricRegistry); + } +} diff --git a/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherCommand.java b/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherCommand.java new file mode 100644 index 000000000..eeaf43468 --- /dev/null +++ b/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherCommand.java @@ -0,0 +1,320 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.netflix.hystrix.contrib.codahalemetricspublisher; + +import com.codahale.metrics.Gauge; +import com.codahale.metrics.MetricRegistry; +import com.netflix.hystrix.HystrixCircuitBreaker; +import com.netflix.hystrix.HystrixCommandGroupKey; +import com.netflix.hystrix.HystrixCommandKey; +import com.netflix.hystrix.HystrixCommandMetrics; +import com.netflix.hystrix.HystrixCommandProperties; +import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherCommand; +import com.netflix.hystrix.util.HystrixRollingNumberEvent; + +/** + * Implementation of {@link HystrixMetricsPublisherCommand} using Coda Hale Metrics (https://github.com/codahale/metrics) + */ +public class HystrixCodaHaleMetricsPublisherCommand implements HystrixMetricsPublisherCommand { + private final HystrixCommandKey key; + private final HystrixCommandGroupKey commandGroupKey; + private final HystrixCommandMetrics metrics; + private final HystrixCircuitBreaker circuitBreaker; + private final HystrixCommandProperties properties; + private final MetricRegistry metricRegistry; + private final String metricGroup; + private final String metricType; + + public HystrixCodaHaleMetricsPublisherCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties, MetricRegistry metricRegistry) { + this.key = commandKey; + this.commandGroupKey = commandGroupKey; + this.metrics = metrics; + this.circuitBreaker = circuitBreaker; + this.properties = properties; + this.metricRegistry = metricRegistry; + this.metricGroup = "HystrixCommand"; + this.metricType = key.name(); + } + + @Override + public void initialize() { + metricRegistry.register(createMetricName("isCircuitBreakerOpen"), new Gauge() { + @Override + public Boolean getValue() { + return circuitBreaker.isOpen(); + } + }); + + // allow monitor to know exactly at what point in time these stats are for so they can be plotted accurately + metricRegistry.register(createMetricName("currentTime"), new Gauge() { + @Override + public Long getValue() { + return System.currentTimeMillis(); + } + }); + + // cumulative counts + createCumulativeCountForEvent("countCollapsedRequests", HystrixRollingNumberEvent.COLLAPSED); + createCumulativeCountForEvent("countExceptionsThrown", HystrixRollingNumberEvent.EXCEPTION_THROWN); + createCumulativeCountForEvent("countFailure", HystrixRollingNumberEvent.FAILURE); + createCumulativeCountForEvent("countFallbackFailure", HystrixRollingNumberEvent.FALLBACK_FAILURE); + createCumulativeCountForEvent("countFallbackRejection", HystrixRollingNumberEvent.FALLBACK_REJECTION); + createCumulativeCountForEvent("countFallbackSuccess", HystrixRollingNumberEvent.FALLBACK_SUCCESS); + createCumulativeCountForEvent("countResponsesFromCache", HystrixRollingNumberEvent.RESPONSE_FROM_CACHE); + createCumulativeCountForEvent("countSemaphoreRejected", HystrixRollingNumberEvent.SEMAPHORE_REJECTED); + createCumulativeCountForEvent("countShortCircuited", HystrixRollingNumberEvent.SHORT_CIRCUITED); + createCumulativeCountForEvent("countSuccess", HystrixRollingNumberEvent.SUCCESS); + createCumulativeCountForEvent("countThreadPoolRejected", HystrixRollingNumberEvent.THREAD_POOL_REJECTED); + createCumulativeCountForEvent("countTimeout", HystrixRollingNumberEvent.TIMEOUT); + + // rolling counts + createRollingCountForEvent("rollingCountCollapsedRequests", HystrixRollingNumberEvent.COLLAPSED); + createRollingCountForEvent("rollingCountExceptionsThrown", HystrixRollingNumberEvent.EXCEPTION_THROWN); + createRollingCountForEvent("rollingCountFailure", HystrixRollingNumberEvent.FAILURE); + createRollingCountForEvent("rollingCountFallbackFailure", HystrixRollingNumberEvent.FALLBACK_FAILURE); + createRollingCountForEvent("rollingCountFallbackRejection", HystrixRollingNumberEvent.FALLBACK_REJECTION); + createRollingCountForEvent("rollingCountFallbackSuccess", HystrixRollingNumberEvent.FALLBACK_SUCCESS); + createRollingCountForEvent("rollingCountResponsesFromCache", HystrixRollingNumberEvent.RESPONSE_FROM_CACHE); + createRollingCountForEvent("rollingCountSemaphoreRejected", HystrixRollingNumberEvent.SEMAPHORE_REJECTED); + createRollingCountForEvent("rollingCountShortCircuited", HystrixRollingNumberEvent.SHORT_CIRCUITED); + createRollingCountForEvent("rollingCountSuccess", HystrixRollingNumberEvent.SUCCESS); + createRollingCountForEvent("rollingCountThreadPoolRejected", HystrixRollingNumberEvent.THREAD_POOL_REJECTED); + createRollingCountForEvent("rollingCountTimeout", HystrixRollingNumberEvent.TIMEOUT); + + // the number of executionSemaphorePermits in use right now + metricRegistry.register(createMetricName("executionSemaphorePermitsInUse"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getCurrentConcurrentExecutionCount(); + } + }); + + // error percentage derived from current metrics + metricRegistry.register(createMetricName("errorPercentage"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getHealthCounts().getErrorPercentage(); + } + }); + + // latency metrics + metricRegistry.register(createMetricName("latencyExecute_mean"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getExecutionTimeMean(); + } + }); + metricRegistry.register(createMetricName("latencyExecute_percentile_5"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getExecutionTimePercentile(5); + } + }); + metricRegistry.register(createMetricName("latencyExecute_percentile_25"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getExecutionTimePercentile(25); + } + }); + metricRegistry.register(createMetricName("latencyExecute_percentile_50"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getExecutionTimePercentile(50); + } + }); + metricRegistry.register(createMetricName("latencyExecute_percentile_75"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getExecutionTimePercentile(75); + } + }); + metricRegistry.register(createMetricName("latencyExecute_percentile_90"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getExecutionTimePercentile(90); + } + }); + metricRegistry.register(createMetricName("latencyExecute_percentile_99"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getExecutionTimePercentile(99); + } + }); + metricRegistry.register(createMetricName("latencyExecute_percentile_995"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getExecutionTimePercentile(99.5); + } + }); + + metricRegistry.register(createMetricName("latencyTotal_mean"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getTotalTimeMean(); + } + }); + metricRegistry.register(createMetricName("latencyTotal_percentile_5"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getTotalTimePercentile(5); + } + }); + metricRegistry.register(createMetricName("latencyTotal_percentile_25"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getTotalTimePercentile(25); + } + }); + metricRegistry.register(createMetricName("latencyTotal_percentile_50"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getTotalTimePercentile(50); + } + }); + metricRegistry.register(createMetricName("latencyTotal_percentile_75"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getTotalTimePercentile(75); + } + }); + metricRegistry.register(createMetricName("latencyTotal_percentile_90"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getTotalTimePercentile(90); + } + }); + metricRegistry.register(createMetricName("latencyTotal_percentile_99"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getTotalTimePercentile(99); + } + }); + metricRegistry.register(createMetricName("latencyTotal_percentile_995"), new Gauge() { + @Override + public Integer getValue() { + return metrics.getTotalTimePercentile(99.5); + } + }); + + // group + metricRegistry.register(createMetricName("commandGroup"), new Gauge() { + @Override + public String getValue() { + return commandGroupKey != null ? commandGroupKey.name() : null; + } + }); + + // properties (so the values can be inspected and monitored) + metricRegistry.register(createMetricName("propertyValue_rollingStatisticalWindowInMilliseconds"), new Gauge() { + @Override + public Number getValue() { + return properties.metricsRollingStatisticalWindowInMilliseconds().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_circuitBreakerRequestVolumeThreshold"), new Gauge() { + @Override + public Number getValue() { + return properties.circuitBreakerRequestVolumeThreshold().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_circuitBreakerSleepWindowInMilliseconds"), new Gauge() { + @Override + public Number getValue() { + return properties.circuitBreakerSleepWindowInMilliseconds().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_circuitBreakerErrorThresholdPercentage"), new Gauge() { + @Override + public Number getValue() { + return properties.circuitBreakerErrorThresholdPercentage().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_circuitBreakerForceOpen"), new Gauge() { + @Override + public Boolean getValue() { + return properties.circuitBreakerForceOpen().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_circuitBreakerForceClosed"), new Gauge() { + @Override + public Boolean getValue() { + return properties.circuitBreakerForceClosed().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_executionIsolationThreadTimeoutInMilliseconds"), new Gauge() { + @Override + public Number getValue() { + return properties.executionIsolationThreadTimeoutInMilliseconds().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_executionIsolationStrategy"), new Gauge() { + @Override + public String getValue() { + return properties.executionIsolationStrategy().get().name(); + } + }); + metricRegistry.register(createMetricName("propertyValue_metricsRollingPercentileEnabled"), new Gauge() { + @Override + public Boolean getValue() { + return properties.metricsRollingPercentileEnabled().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_requestCacheEnabled"), new Gauge() { + @Override + public Boolean getValue() { + return properties.requestCacheEnabled().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_requestLogEnabled"), new Gauge() { + @Override + public Boolean getValue() { + return properties.requestLogEnabled().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_executionIsolationSemaphoreMaxConcurrentRequests"), new Gauge() { + @Override + public Number getValue() { + return properties.executionIsolationSemaphoreMaxConcurrentRequests().get(); + } + }); + metricRegistry.register(createMetricName("propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests"), new Gauge() { + @Override + public Number getValue() { + return properties.fallbackIsolationSemaphoreMaxConcurrentRequests().get(); + } + }); + } + + protected String createMetricName(String name) { + return MetricRegistry.name(metricGroup, metricType, name); + } + + protected void createCumulativeCountForEvent(String name, final HystrixRollingNumberEvent event) { + metricRegistry.register(createMetricName(name), new Gauge() { + @Override + public Long getValue() { + return metrics.getCumulativeCount(event); + } + }); + } + + protected void createRollingCountForEvent(String name, final HystrixRollingNumberEvent event) { + metricRegistry.register(createMetricName(name), new Gauge() { + @Override + public Long getValue() { + return metrics.getRollingCount(event); + } + }); + } +} diff --git a/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherThreadPool.java b/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherThreadPool.java new file mode 100644 index 000000000..1682cc564 --- /dev/null +++ b/hystrix-contrib/hystrix-codahale-metrics-publisher/src/main/java/com/netflix/hystrix/contrib/codahalemetricspublisher/HystrixCodaHaleMetricsPublisherThreadPool.java @@ -0,0 +1,149 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.netflix.hystrix.contrib.codahalemetricspublisher; + +import com.codahale.metrics.Gauge; +import com.codahale.metrics.MetricRegistry; +import com.netflix.hystrix.HystrixThreadPoolKey; +import com.netflix.hystrix.HystrixThreadPoolMetrics; +import com.netflix.hystrix.HystrixThreadPoolProperties; +import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisherThreadPool; + +/** + * Implementation of {@link HystrixMetricsPublisherThreadPool} using Coda Hale Metrics (https://github.com/codahale/metrics) + */ +public class HystrixCodaHaleMetricsPublisherThreadPool implements HystrixMetricsPublisherThreadPool { + private final HystrixThreadPoolKey key; + private final HystrixThreadPoolMetrics metrics; + private final HystrixThreadPoolProperties properties; + private final MetricRegistry metricRegistry; + private final String metricGroup; + private final String metricType; + + public HystrixCodaHaleMetricsPublisherThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, HystrixThreadPoolProperties properties, MetricRegistry metricRegistry) { + this.key = threadPoolKey; + this.metrics = metrics; + this.properties = properties; + this.metricRegistry = metricRegistry; + this.metricGroup = "HystrixThreadPool"; + this.metricType = key.name(); + } + + @Override + public void initialize() { + metricRegistry.register(createMetricName("name"), new Gauge() { + @Override + public String getValue() { + return key.name(); + } + }); + + // allow monitor to know exactly at what point in time these stats are for so they can be plotted accurately + metricRegistry.register(createMetricName("currentTime"), new Gauge() { + @Override + public Long getValue() { + return System.currentTimeMillis(); + } + }); + + metricRegistry.register(createMetricName("threadActiveCount"), new Gauge() { + @Override + public Number getValue() { + return metrics.getCurrentActiveCount(); + } + }); + + metricRegistry.register(createMetricName("completedTaskCount"), new Gauge() { + @Override + public Number getValue() { + return metrics.getCurrentCompletedTaskCount(); + } + }); + + metricRegistry.register(createMetricName("largestPoolSize"), new Gauge() { + @Override + public Number getValue() { + return metrics.getCurrentLargestPoolSize(); + } + }); + + metricRegistry.register(createMetricName("totalTaskCount"), new Gauge() { + @Override + public Number getValue() { + return metrics.getCurrentTaskCount(); + } + }); + + metricRegistry.register(createMetricName("queueSize"), new Gauge() { + @Override + public Number getValue() { + return metrics.getCurrentQueueSize(); + } + }); + + metricRegistry.register(createMetricName("rollingMaxActiveThreads"), new Gauge() { + @Override + public Number getValue() { + return metrics.getRollingMaxActiveThreads(); + } + }); + + metricRegistry.register(createMetricName("countThreadsExecuted"), new Gauge() { + @Override + public Number getValue() { + return metrics.getCumulativeCountThreadsExecuted(); + } + }); + + metricRegistry.register(createMetricName("rollingCountThreadsExecuted"), new Gauge() { + @Override + public Number getValue() { + return metrics.getRollingCountThreadsExecuted(); + } + }); + + // properties + metricRegistry.register(createMetricName("propertyValue_corePoolSize"), new Gauge() { + @Override + public Number getValue() { + return properties.coreSize().get(); + } + }); + + metricRegistry.register(createMetricName("propertyValue_keepAliveTimeInMinutes"), new Gauge() { + @Override + public Number getValue() { + return properties.keepAliveTimeMinutes().get(); + } + }); + + metricRegistry.register(createMetricName("propertyValue_queueSizeRejectionThreshold"), new Gauge() { + @Override + public Number getValue() { + return properties.queueSizeRejectionThreshold().get(); + } + }); + + metricRegistry.register(createMetricName("propertyValue_maxQueueSize"), new Gauge() { + @Override + public Number getValue() { + return properties.maxQueueSize().get(); + } + }); + } + + protected String createMetricName(String name) { + return MetricRegistry.name(metricGroup, metricType, name); + } +} diff --git a/settings.gradle b/settings.gradle index 67d052f1c..d44c56f5f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,6 +6,7 @@ include 'hystrix-core', \ 'hystrix-contrib:hystrix-request-servlet', \ 'hystrix-contrib:hystrix-servo-metrics-publisher', \ 'hystrix-contrib:hystrix-metrics-event-stream', \ +'hystrix-contrib:hystrix-codahale-metrics-publisher', \ 'hystrix-contrib:hystrix-yammer-metrics-publisher', \ 'hystrix-contrib:hystrix-network-auditor-agent', \ 'hystrix-dashboard' From e22d3ed9a64e8259ef5158f20643d7385e969b35 Mon Sep 17 00:00:00 2001 From: Fredrik Kjellberg Date: Sun, 24 Nov 2013 18:12:50 +0100 Subject: [PATCH 2/2] Update docs to link between the modules for Coda Hale/Yammer Metrics version 2 and 3. --- hystrix-contrib/hystrix-codahale-metrics-publisher/README.md | 2 +- hystrix-contrib/hystrix-yammer-metrics-publisher/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hystrix-contrib/hystrix-codahale-metrics-publisher/README.md b/hystrix-contrib/hystrix-codahale-metrics-publisher/README.md index 62d360ae7..02e2cc76b 100644 --- a/hystrix-contrib/hystrix-codahale-metrics-publisher/README.md +++ b/hystrix-contrib/hystrix-codahale-metrics-publisher/README.md @@ -1,6 +1,6 @@ # hystrix-codahale-metrics-publisher -This is an implementation of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/index.html?com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) that publishes metrics using [Coda Hale Metrics](http://metrics.codahale.com). +This is an implementation of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/index.html?com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) that publishes metrics using [Coda Hale Metrics](http://metrics.codahale.com) version 3. If you are using Yammer Metrics version 2, please use the [hystrix-yammer-metrics-publisher](../hystrix-yammer-metrics-publisher) module instead. See the [Metrics & Monitoring](https://github.com/Netflix/Hystrix/wiki/Metrics-and-Monitoring) Wiki for more information. diff --git a/hystrix-contrib/hystrix-yammer-metrics-publisher/README.md b/hystrix-contrib/hystrix-yammer-metrics-publisher/README.md index 7d86d964f..3f167b4e1 100644 --- a/hystrix-contrib/hystrix-yammer-metrics-publisher/README.md +++ b/hystrix-contrib/hystrix-yammer-metrics-publisher/README.md @@ -1,6 +1,6 @@ # hystrix-yammer-metrics-publisher -This is an implementation of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/index.html?com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) that publishes metrics using [Yammer Metrics](http://metrics.codahale.com). +This is an implementation of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/index.html?com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) that publishes metrics using [Yammer Metrics](http://metrics.codahale.com) version 2. If you are using Coda Hale Metrics version 3, please use the [hystrix-codahale-metrics-publisher](../hystrix-codahale-metrics-publisher) module instead. See the [Metrics & Monitoring](https://github.com/Netflix/Hystrix/wiki/Metrics-and-Monitoring) Wiki for more information.