Skip to content

Commit 6c3ffcb

Browse files
garyrussellartembilan
authored andcommitted
GH-2803: Deprecate legacy metrics
Resolves #2803 * Polishing - PR Comments * More PR Comments * Missed one comment
1 parent 43d03c3 commit 6c3ffcb

File tree

68 files changed

+660
-279
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+660
-279
lines changed

spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractCorrelatingMessageHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.springframework.aop.framework.ProxyFactory;
3333
import org.springframework.beans.factory.BeanFactory;
3434
import org.springframework.beans.factory.BeanFactoryAware;
35-
import org.springframework.beans.factory.DisposableBean;
3635
import org.springframework.context.ApplicationEventPublisher;
3736
import org.springframework.context.ApplicationEventPublisherAware;
3837
import org.springframework.context.Lifecycle;
@@ -92,7 +91,7 @@
9291
* @since 2.0
9392
*/
9493
public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageProducingHandler
95-
implements DiscardingMessageHandler, DisposableBean, ApplicationEventPublisherAware, Lifecycle {
94+
implements DiscardingMessageHandler, ApplicationEventPublisherAware, Lifecycle {
9695

9796
private final Comparator<Message<?>> sequenceNumberComparator = new MessageSequenceComparator();
9897

spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageGroupProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.Map;
2020

2121
import org.springframework.beans.factory.BeanFactory;
22-
import org.springframework.beans.factory.BeanFactoryAware;
2322
import org.springframework.core.convert.ConversionService;
2423
import org.springframework.integration.store.MessageGroup;
2524

@@ -32,7 +31,7 @@
3231
* @author Dave Syer
3332
* @author Gary Russell
3433
*/
35-
public class ExpressionEvaluatingMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor implements BeanFactoryAware {
34+
public class ExpressionEvaluatingMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor {
3635

3736
private final ExpressionEvaluatingMessageListProcessor processor;
3837

spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
import org.springframework.integration.support.management.ConfigurableMetricsAware;
3838
import org.springframework.integration.support.management.DefaultMessageChannelMetrics;
3939
import org.springframework.integration.support.management.IntegrationManagedResource;
40-
import org.springframework.integration.support.management.MessageChannelMetrics;
41-
import org.springframework.integration.support.management.MetricsContext;
42-
import org.springframework.integration.support.management.Statistics;
4340
import org.springframework.integration.support.management.TrackableComponent;
4441
import org.springframework.integration.support.management.metrics.MeterFacade;
4542
import org.springframework.integration.support.management.metrics.MetricsCaptor;
@@ -69,7 +66,8 @@
6966
@IntegrationManagedResource
7067
@SuppressWarnings("deprecation")
7168
public abstract class AbstractMessageChannel extends IntegrationObjectSupport
72-
implements MessageChannel, TrackableComponent, ChannelInterceptorAware, MessageChannelMetrics,
69+
implements MessageChannel, TrackableComponent, ChannelInterceptorAware,
70+
org.springframework.integration.support.management.MessageChannelMetrics,
7371
ConfigurableMetricsAware<AbstractMessageChannelMetrics> {
7472

7573
protected final ChannelInterceptorList interceptors; // NOSONAR
@@ -117,8 +115,8 @@ public void setShouldTrack(boolean shouldTrack) {
117115
}
118116

119117
@Override
120-
public void registerMetricsCaptor(MetricsCaptor metricsCaptor) {
121-
this.metricsCaptor = metricsCaptor;
118+
public void registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister) {
119+
this.metricsCaptor = metricsCaptorToRegister;
122120
}
123121

124122
@Nullable
@@ -335,17 +333,17 @@ public double getStandardDeviationSendDuration() {
335333
}
336334

337335
@Override
338-
public Statistics getSendDuration() {
336+
public org.springframework.integration.support.management.Statistics getSendDuration() {
339337
return this.channelMetrics.getSendDuration();
340338
}
341339

342340
@Override
343-
public Statistics getSendRate() {
341+
public org.springframework.integration.support.management.Statistics getSendRate() {
344342
return this.channelMetrics.getSendRate();
345343
}
346344

347345
@Override
348-
public Statistics getErrorRate() {
346+
public org.springframework.integration.support.management.Statistics getErrorRate() {
349347
return this.channelMetrics.getErrorRate();
350348
}
351349

@@ -429,7 +427,7 @@ public boolean send(Message<?> messageArg, long timeout) {
429427
Deque<ChannelInterceptor> interceptorStack = null;
430428
boolean sent = false;
431429
boolean metricsProcessed = false;
432-
MetricsContext metricsContext = null;
430+
org.springframework.integration.support.management.MetricsContext metricsContext = null;
433431
boolean countsAreEnabled = this.countsEnabled;
434432
ChannelInterceptorList interceptorList = this.interceptors;
435433
AbstractMessageChannelMetrics metrics = this.channelMetrics;

spring-integration-core/src/main/java/org/springframework/integration/channel/NullChannel.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import org.springframework.integration.support.management.ConfigurableMetricsAware;
2828
import org.springframework.integration.support.management.DefaultMessageChannelMetrics;
2929
import org.springframework.integration.support.management.IntegrationManagedResource;
30-
import org.springframework.integration.support.management.MessageChannelMetrics;
31-
import org.springframework.integration.support.management.Statistics;
3230
import org.springframework.integration.support.management.metrics.MetricsCaptor;
3331
import org.springframework.integration.support.management.metrics.TimerFacade;
3432
import org.springframework.lang.Nullable;
@@ -47,7 +45,9 @@
4745
* @author Artyem Bilan
4846
*/
4947
@IntegrationManagedResource
50-
public class NullChannel implements PollableChannel, MessageChannelMetrics,
48+
@SuppressWarnings("deprecation")
49+
public class NullChannel implements PollableChannel,
50+
org.springframework.integration.support.management.MessageChannelMetrics,
5151
ConfigurableMetricsAware<AbstractMessageChannelMetrics>, BeanNameAware, NamedComponent {
5252

5353
private final Log logger = LogFactory.getLog(getClass());
@@ -211,17 +211,17 @@ public double getStandardDeviationSendDuration() {
211211
}
212212

213213
@Override
214-
public Statistics getSendDuration() {
214+
public org.springframework.integration.support.management.Statistics getSendDuration() {
215215
return this.channelMetrics.getSendDuration();
216216
}
217217

218218
@Override
219-
public Statistics getSendRate() {
219+
public org.springframework.integration.support.management.Statistics getSendRate() {
220220
return this.channelMetrics.getSendRate();
221221
}
222222

223223
@Override
224-
public Statistics getErrorRate() {
224+
public org.springframework.integration.support.management.Statistics getErrorRate() {
225225
return this.channelMetrics.getErrorRate();
226226
}
227227

spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ThreadStatePropagationChannelInterceptor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.springframework.messaging.MessageChannel;
2222
import org.springframework.messaging.MessageHandler;
2323
import org.springframework.messaging.MessageHeaders;
24-
import org.springframework.messaging.support.ChannelInterceptor;
2524
import org.springframework.messaging.support.ExecutorChannelInterceptor;
2625

2726
/**
@@ -51,7 +50,7 @@
5150
* @since 4.2
5251
*/
5352
public abstract class ThreadStatePropagationChannelInterceptor<S>
54-
implements ChannelInterceptor, ExecutorChannelInterceptor {
53+
implements ExecutorChannelInterceptor {
5554

5655
@Override
5756
public final Message<?> preSend(Message<?> message, MessageChannel channel) {

spring-integration-core/src/main/java/org/springframework/integration/config/EnableIntegrationManagement.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.lang.annotation.Target;
2424

2525
import org.springframework.context.annotation.Import;
26+
import org.springframework.core.annotation.AliasFor;
2627

2728
/**
2829
* Enables default configuring of management in Spring Integration components in an existing application.
@@ -53,9 +54,29 @@
5354
* Defaults to no components, unless JMX is enabled in which case, defaults to all
5455
* components. Overrides {@link #defaultCountsEnabled()} for matching bean names.
5556
* @return the patterns.
57+
* @deprecated in favor of 'metersEnabled'.
5658
*/
59+
@Deprecated
60+
@AliasFor("metersEnabled")
5761
String[] countsEnabled() default "*";
5862

63+
/**
64+
* A list of simple patterns for component names for which message counts will be
65+
* enabled (defaults to '*'). Enables message
66+
* counting (`sendCount`, `errorCount`, `receiveCount`) for those components that
67+
* support counters (channels, message handlers, etc). This is the initial setting
68+
* only, individual components can have counts enabled/disabled at runtime. May be
69+
* overridden by an entry in {@link #statsEnabled() statsEnabled} which is additional
70+
* functionality over simple counts. If a pattern starts with `!`, counts are disabled
71+
* for matches. For components that match multiple patterns, the first pattern wins.
72+
* Disabling counts at runtime also disables stats.
73+
* Defaults to no components, unless JMX is enabled in which case, defaults to all
74+
* components. Overrides {@link #defaultCountsEnabled()} for matching bean names.
75+
* @return the patterns.
76+
*/
77+
@AliasFor("countsEnabled")
78+
String[] metersEnabled() default "*";
79+
5980
/**
6081
* A list of simple patterns for component names for which message statistics will be
6182
* enabled (response times, rates etc), as well as counts (a positive match here
@@ -72,7 +93,11 @@
7293
* Defaults to no components, unless JMX is enabled in which case, defaults to all
7394
* components.
7495
* @return the patterns.
96+
* @deprecated in favor of dimensional metrics via
97+
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
98+
* Built-in metrics will be removed in a future release.
7599
*/
100+
@Deprecated
76101
String[] statsEnabled() default "*";
77102

78103
/**
@@ -86,7 +111,11 @@
86111
* The default setting for enabling statistics when a bean name is not matched by
87112
* {@link #statsEnabled() statsEnabled}.
88113
* @return the value; false by default, or true when JMX is enabled.
114+
* @deprecated in favor of dimensional metrics via
115+
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
116+
* Built-in metrics will be removed in a future release.
89117
*/
118+
@Deprecated
90119
String defaultStatsEnabled() default "false";
91120

92121
/**
@@ -113,7 +142,11 @@
113142
* The bean name of a {@code MetricsFactory}. The {@code DefaultMetricsFactory} is used
114143
* if omitted.
115144
* @return the bean name.
145+
* @deprecated in favor of dimensional metrics via
146+
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
147+
* Built-in metrics will be removed in a future release.
116148
*/
149+
@Deprecated
117150
String metricsFactory() default "";
118151

119152
}

spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationManagementConfiguration.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public void setImportMetadata(AnnotationMetadata importMetadata) {
6464
"@EnableIntegrationManagement is not present on importing class " + importMetadata.getClassName());
6565
}
6666

67+
@SuppressWarnings("deprecation")
6768
@Bean(name = IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME)
6869
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
6970
public IntegrationManagementConfigurer managementConfigurer() {
@@ -90,17 +91,18 @@ private void setupCountsEnabledNamePatterns(IntegrationManagementConfigurer conf
9091
String pattern = this.environment.resolvePlaceholders(managedComponent);
9192
patterns.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(pattern)));
9293
}
93-
configurer.setEnabledCountsPatterns(patterns.toArray(new String[patterns.size()]));
94+
configurer.setEnabledCountsPatterns(patterns.toArray(new String[0]));
9495
}
9596

97+
@SuppressWarnings("deprecation")
9698
private void setupStatsEnabledNamePatterns(IntegrationManagementConfigurer configurer) {
97-
List<String> patterns = new ArrayList<String>();
99+
List<String> patterns = new ArrayList<>();
98100
String[] statsEnabled = this.attributes.getStringArray("statsEnabled");
99101
for (String managedComponent : statsEnabled) {
100102
String pattern = this.environment.resolvePlaceholders(managedComponent);
101103
patterns.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(pattern)));
102104
}
103-
configurer.setEnabledStatsPatterns(patterns.toArray(new String[patterns.size()]));
105+
configurer.setEnabledStatsPatterns(patterns.toArray(new String[0]));
104106
}
105107

106108
}

0 commit comments

Comments
 (0)