Update to BOOT 2.0.0.BUILD-SNAPSHOT
- Fixes #1088 - Updates Actuator endpoints - Removing metrics dependencies for now, we will revisit metrics and stream on a separate PR
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>2.0.0.M2</version>
|
||||
<version>2.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<scm>
|
||||
@@ -110,7 +110,7 @@
|
||||
<module>spring-cloud-stream-schema</module>
|
||||
<module>spring-cloud-stream-schema-server</module>
|
||||
<module>spring-cloud-stream-tools</module>
|
||||
<module>spring-cloud-stream-metrics</module>
|
||||
<!--<module>spring-cloud-stream-metrics</module>-->
|
||||
</modules>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
|
||||
@@ -28,9 +28,7 @@ import java.util.Set;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.endpoint.MetricReaderPublicMetrics;
|
||||
import org.springframework.boot.actuate.endpoint.MetricsEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
|
||||
@@ -46,7 +44,6 @@ import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -58,6 +55,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Marius Bogoevici
|
||||
* @author Venil Noronha
|
||||
* @author Janne Valkealahti
|
||||
* @author Vinicius Carvalho
|
||||
*/
|
||||
@EnableBinding
|
||||
public class AggregateApplicationBuilder implements AggregateApplication, ApplicationContextAware,
|
||||
@@ -419,16 +417,7 @@ public class AggregateApplicationBuilder implements AggregateApplication, Applic
|
||||
e);
|
||||
}
|
||||
}
|
||||
// Register metrics if JMX enabled and exporter avalable
|
||||
if (BeanFactoryUtils.beansOfTypeIncludingAncestors(AggregateApplicationBuilder.this.parentContext,
|
||||
IntegrationMBeanExporter.class).size() > 0) {
|
||||
BeanFactoryUtils
|
||||
.beanOfTypeIncludingAncestors(AggregateApplicationBuilder.this.parentContext,
|
||||
MetricsEndpoint.class)
|
||||
.registerPublicMetrics(
|
||||
new MetricReaderPublicMetrics(new NamespaceAwareSpringIntegrationMetricReader(
|
||||
this.namespace, childContext.getBean(IntegrationMBeanExporter.class))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public AggregateApplication build() {
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
*
|
||||
* 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 org.springframework.cloud.stream.aggregate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.actuate.metrics.Metric;
|
||||
import org.springframework.boot.actuate.metrics.reader.MetricReader;
|
||||
import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
||||
import org.springframework.integration.support.management.Statistics;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A customized version of
|
||||
* {@link org.springframework.boot.actuate.metrics.integration.SpringIntegrationMetricReader}
|
||||
* that provides support for customizing channels with a namespace prefix.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
* @see org.springframework.boot.actuate.metrics.integration.SpringIntegrationMetricReader
|
||||
* for original implementation
|
||||
*/
|
||||
public class NamespaceAwareSpringIntegrationMetricReader implements MetricReader {
|
||||
|
||||
private final String namespace;
|
||||
|
||||
private final IntegrationMBeanExporter exporter;
|
||||
|
||||
public NamespaceAwareSpringIntegrationMetricReader(String namespace, IntegrationMBeanExporter exporter) {
|
||||
Assert.hasText(namespace, "cannot be null or empty String");
|
||||
Assert.notNull(exporter, "cannot be null");
|
||||
this.namespace = namespace;
|
||||
this.exporter = exporter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Metric<?> findOne(String metricName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Metric<?>> findAll() {
|
||||
IntegrationMBeanExporter exporter = this.exporter;
|
||||
List<Metric<?>> metrics = new ArrayList<Metric<?>>();
|
||||
for (String name : exporter.getChannelNames()) {
|
||||
String prefix = "integration.channel." + namespace + "." + name;
|
||||
metrics.addAll(getStatistics(prefix + ".errorRate",
|
||||
exporter.getChannelErrorRate(name)));
|
||||
metrics.add(new Metric<Long>(prefix + ".sendCount",
|
||||
exporter.getChannelSendCountLong(name)));
|
||||
metrics.addAll(getStatistics(prefix + ".sendRate",
|
||||
exporter.getChannelSendRate(name)));
|
||||
metrics.add(new Metric<Long>(prefix + ".receiveCount",
|
||||
exporter.getChannelReceiveCountLong(name)));
|
||||
}
|
||||
for (String name : exporter.getHandlerNames()) {
|
||||
metrics.addAll(getStatistics("integration." + namespace + ".handler." + name + ".duration",
|
||||
exporter.getHandlerDuration(name)));
|
||||
}
|
||||
metrics.add(new Metric<Integer>("integration." + namespace + ".activeHandlerCount",
|
||||
exporter.getActiveHandlerCount()));
|
||||
metrics.add(new Metric<Integer>("integration." + namespace + ".handlerCount",
|
||||
exporter.getHandlerCount()));
|
||||
metrics.add(new Metric<Integer>("integration." + namespace + ".channelCount",
|
||||
exporter.getChannelCount()));
|
||||
metrics.add(new Metric<Integer>("integration." + namespace + ".queuedMessageCount",
|
||||
exporter.getQueuedMessageCount()));
|
||||
return metrics;
|
||||
}
|
||||
|
||||
private Collection<? extends Metric<?>> getStatistics(String name,
|
||||
Statistics statistic) {
|
||||
List<Metric<?>> metrics = new ArrayList<Metric<?>>();
|
||||
metrics.add(new Metric<Double>(name + ".mean", statistic.getMean()));
|
||||
metrics.add(new Metric<Double>(name + ".max", statistic.getMax()));
|
||||
metrics.add(new Metric<Double>(name + ".min", statistic.getMin()));
|
||||
metrics.add(
|
||||
new Metric<Double>(name + ".stdev", statistic.getStandardDeviation()));
|
||||
metrics.add(new Metric<Long>(name + ".count", statistic.getCountLong()));
|
||||
return metrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
int totalChannelCount = this.exporter.getChannelCount() * 11;
|
||||
int totalHandlerCount = this.exporter.getHandlerCount() * 5;
|
||||
return totalChannelCount + totalHandlerCount + 4;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cloud.stream.config;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.actuate.autoconfigure.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.CompositeHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.cloud.stream.config;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @author Ilayaperumal Gopinathan
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(name = "org.springframework.boot.actuate.endpoint.Endpoint")
|
||||
@ConditionalOnClass(name = "org.springframework.boot.actuate.endpoint.annotation.Endpoint")
|
||||
@ConditionalOnBean(BindingService.class)
|
||||
@AutoConfigureAfter(EndpointAutoConfiguration.class)
|
||||
public class ChannelsEndpointAutoConfiguration {
|
||||
|
||||
@@ -25,8 +25,8 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
import org.springframework.cloud.stream.binding.Bindable;
|
||||
import org.springframework.cloud.stream.config.BindingProperties;
|
||||
import org.springframework.cloud.stream.config.BindingServiceProperties;
|
||||
@@ -37,21 +37,22 @@ import org.springframework.cloud.stream.config.BindingServiceProperties;
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Ilayaperumal Gopinathan
|
||||
* @author Vinicius Carvalho
|
||||
*/
|
||||
public class ChannelsEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||
@Endpoint(id = "channels")
|
||||
public class ChannelsEndpoint {
|
||||
|
||||
private List<Bindable> adapters;
|
||||
|
||||
private BindingServiceProperties properties;
|
||||
|
||||
public ChannelsEndpoint(List<Bindable> adapters, BindingServiceProperties properties) {
|
||||
super("channels");
|
||||
this.adapters = adapters;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> invoke() {
|
||||
@ReadOperation
|
||||
public Map<String, Object> channels() {
|
||||
ChannelsMetaData map = new ChannelsMetaData();
|
||||
Map<String, BindingProperties> inputs = map.getInputs();
|
||||
Map<String, BindingProperties> outputs = map.getOutputs();
|
||||
|
||||
Reference in New Issue
Block a user