Export MessageChannel metric writer

Update the auto-configured MessageChannelMetricWriter with
@ExportMetricWriter so that metrics are actually exported.

Fixes gh-5517
This commit is contained in:
Phillip Webb 2016-04-09 22:04:58 -07:00
parent 02764b8ff3
commit 3ca365cff0
2 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,6 +41,7 @@ import org.springframework.messaging.MessageChannel;
public class MetricsChannelAutoConfiguration { public class MetricsChannelAutoConfiguration {
@Bean @Bean
@ExportMetricWriter
@ConditionalOnMissingBean @ConditionalOnMissingBean
public MessageChannelMetricWriter messageChannelMetricWriter( public MessageChannelMetricWriter messageChannelMetricWriter(
@Qualifier("metricsChannel") MessageChannel channel) { @Qualifier("metricsChannel") MessageChannel channel) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -45,6 +45,7 @@ import org.springframework.messaging.SubscribableChannel;
import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/** /**
* Tests for {@link MetricExportAutoConfiguration}. * Tests for {@link MetricExportAutoConfiguration}.
@ -77,6 +78,7 @@ public class MetricExportAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration.class); PropertyPlaceholderAutoConfiguration.class);
MetricExporters exporter = this.context.getBean(MetricExporters.class); MetricExporters exporter = this.context.getBean(MetricExporters.class);
assertNotNull(exporter); assertNotNull(exporter);
assertTrue(exporter.getExporters().containsKey("messageChannelMetricWriter"));
} }
@Test @Test