Skip to content

Commit f4e1fc6

Browse files
문민규문민규
문민규
authored and
문민규
committed
GH-241: Support changing metrics-level for KclMessageDrivenChannelAdapter
1 parent a82a0b6 commit f4e1fc6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/main/java/org/springframework/integration/aws/inbound/kinesis/KclMessageDrivenChannelAdapter.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 the original author or authors.
2+
* Copyright 2019-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,6 +50,8 @@
5050
import software.amazon.kinesis.lifecycle.events.ProcessRecordsInput;
5151
import software.amazon.kinesis.lifecycle.events.ShardEndedInput;
5252
import software.amazon.kinesis.lifecycle.events.ShutdownRequestedInput;
53+
import software.amazon.kinesis.metrics.MetricsConfig;
54+
import software.amazon.kinesis.metrics.MetricsLevel;
5355
import software.amazon.kinesis.processor.FormerStreamsLeasesDeletionStrategy;
5456
import software.amazon.kinesis.processor.MultiStreamTracker;
5557
import software.amazon.kinesis.processor.RecordProcessorCheckpointer;
@@ -92,6 +94,7 @@
9294
* @author Artem Bilan
9395
* @author Dirk Bonhomme
9496
* @author Siddharth Jain
97+
* @author Minkyu Moon
9598
*
9699
* @since 2.2.0
97100
*/
@@ -145,6 +148,8 @@ public class KclMessageDrivenChannelAdapter extends MessageProducerSupport
145148

146149
private volatile Scheduler scheduler;
147150

151+
private MetricsLevel metricsLevel = MetricsLevel.DETAILED;
152+
148153
public KclMessageDrivenChannelAdapter(String... streams) {
149154
this(KinesisAsyncClient.create(), CloudWatchAsyncClient.create(), DynamoDbAsyncClient.create(), streams);
150155
}
@@ -267,6 +272,16 @@ public void setFanOut(boolean fanOut) {
267272
this.fanOut = fanOut;
268273
}
269274

275+
/**
276+
* Specify a metrics level to emit.
277+
* Defaults to {@link MetricsLevel#DETAILED}.
278+
* @param metricsLevel the {@link MetricsLevel} for emitting (or not) metrics into Cloud Watch.
279+
*/
280+
public void setMetricsLevel(MetricsLevel metricsLevel) {
281+
Assert.notNull(metricsLevel, "'metricsLevel' must not be null");
282+
this.metricsLevel = metricsLevel;
283+
}
284+
270285
@Override
271286
protected void onInit() {
272287
super.onInit();
@@ -321,13 +336,16 @@ protected void doStart() {
321336
.glueSchemaRegistryDeserializer(this.glueSchemaRegistryDeserializer)
322337
.retrievalSpecificConfig(retrievalSpecificConfig);
323338

339+
MetricsConfig metricsConfig = this.config.metricsConfig();
340+
metricsConfig.metricsLevel(this.metricsLevel);
341+
324342
this.scheduler =
325343
new Scheduler(
326344
this.config.checkpointConfig(),
327345
this.config.coordinatorConfig(),
328346
this.config.leaseManagementConfig(),
329347
lifecycleConfig,
330-
this.config.metricsConfig(),
348+
metricsConfig,
331349
this.config.processorConfig(),
332350
retrievalConfig);
333351

0 commit comments

Comments
 (0)