Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-241 Support changing metrics-level for KclMessageDrivenChannelAdapter #242

Merged
merged 5 commits into from
Mar 15, 2024

Conversation

Min3953
Copy link
Contributor

@Min3953 Min3953 commented Mar 15, 2024

Linked issue: #241

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution.
Any chances that you can modify KclMessageDrivenChannelAdapterTests to verify this new option?

/**
* Specify a metrics level to emit (DETAILED; default).
* @param metricsLevel {@link MetricsLevel} DETAILED for emitting all metrics.
* @author Minkyu Moon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move your author name to the class level.

@@ -267,6 +271,15 @@ public void setFanOut(boolean fanOut) {
this.fanOut = fanOut;
}

/**
* Specify a metrics level to emit (DETAILED; default).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Specify a metrics level to emit (DETAILED; default).
* Specify a metrics level to emit.
* Defaults to {@link MetricsLevel#DETAILED}.

@@ -267,6 +271,15 @@ public void setFanOut(boolean fanOut) {
this.fanOut = fanOut;
}

/**
* Specify a metrics level to emit (DETAILED; default).
* @param metricsLevel {@link MetricsLevel} DETAILED for emitting all metrics.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param metricsLevel {@link MetricsLevel} DETAILED for emitting all metrics.
* @param metricsLevel the {@link MetricsLevel} for emitting (or not) metrics into Cloud Watch.

@@ -321,13 +334,18 @@ protected void doStart() {
.glueSchemaRegistryDeserializer(this.glueSchemaRegistryDeserializer)
.retrievalSpecificConfig(retrievalSpecificConfig);

MetricsConfig metricsConfig = this.config.metricsConfig();
if(this.metricsLevel != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need in this if since this.metricsLevel cannot be null.

@artembilan
Copy link
Member

Please, consider to modify a test.
And no need to squash commits: just add a new one - and we will a history properly.
Then on merge it is going to be squashed.
Thanks

@Min3953
Copy link
Contributor Author

Min3953 commented Mar 15, 2024

Thank you for the contribution. Any chances that you can modify KclMessageDrivenChannelAdapterTests to verify this new option?

Thank you for your suggestion for my first contribution.
I have tried to write test that it is right to set MetricsLevel of MetricsConfig by that option, But it is not exposed public.
So I can't write because I didn't know what you wanted to test.
Should there not be metric in CloudWatch that is emitted from kcl consumer?

@Min3953 Min3953 requested a review from artembilan March 15, 2024 14:47
@artembilan
Copy link
Member

Should there not be metric in CloudWatch that is emitted from kcl consumer?

Well, it is not this project responsibility.
I believe there is just enough to be sure that property we set for this new option is propagated properly downstream into the Scheduler.
We have a org.springframework.integration.test.util.TestUtils.getPropertyValue() utility to get the underlying property via reflection.
In our case I guess it would be like this:

TestUtils.getPropertyValue(kclMessageDrivenChannelAdapter, "scheduler.metricsFactory.metricsLevel", MetricsLevel.class)

and compare it with whatever we provide in the kclMessageDrivenChannelAdapter bean configuration.

@Min3953
Copy link
Contributor Author

Min3953 commented Mar 15, 2024

Thank you for your suggestion.

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And your name to that modified test class.

@@ -130,6 +150,7 @@ public KclMessageDrivenChannelAdapter kclMessageDrivenChannelAdapter() {
adapter.setConverter(String::new);
adapter.setConsumerGroup("single_stream_group");
adapter.setFanOut(false);
adapter.setMetricsLevel(MetricsLevel.fromName("NONE"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just enough to use MetricsLevel.NONE.

"scheduler.metricsFactory.metricsLevel",
MetricsLevel.class
);
MetricsLevel expectedMetricsLevel = TestUtils.getPropertyValue(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to do this. There is just enough to compare with the MetricsLevel.NONE.

@Min3953 Min3953 requested a review from artembilan March 15, 2024 15:51
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, but no we have a Checkstyle violations:

Error: eckstyle] [ERROR] /home/runner/work/spring-integration-aws/spring-integration-aws/src/test/java/org/springframework/integration/aws/kinesis/KclMessageDrivenChannelAdapterTests.java:24:1: 'org.springframework.integration.test.util.TestUtils' should be separated from previous imports. [ImportOrder]

Error: eckstyle] [ERROR] /home/runner/work/spring-integration-aws/spring-integration-aws/src/test/java/org/springframework/integration/aws/kinesis/KclMessageDrivenChannelAdapterTests.java:25:1: Wrong order for 'software.amazon.awssdk.core.SdkBytes' import. [ImportOrder]
> Task :checkstyleTest
Error: eckstyle] [ERROR] /home/runner/work/spring-integration-aws/spring-integration-aws/src/test/java/org/springframework/integration/aws/kinesis/KclMessageDrivenChannelAdapterTests.java:46:1: Wrong order for 'software.amazon.kinesis.metrics.MetricsLevel' import. [ImportOrder]
Error: eckstyle] [ERROR] /home/runner/work/spring-integration-aws/spring-integration-aws/src/test/java/org/springframework/integration/aws/kinesis/KclMessageDrivenChannelAdapterTests.java:128:25: Reference to instance variable 'kclMessageDrivenChannelAdapter' needs "this.". [RequireThis]

Please, run locally gradlew check to see all of the with recommendations how to fix.

@Min3953
Copy link
Contributor Author

Min3953 commented Mar 15, 2024

I'm sorry to bother you. I checked Github Actions job, and fixed failure.
I trusted IDE setting too much.

@artembilan artembilan merged commit cf12660 into spring-projects:main Mar 15, 2024
1 check passed
@artembilan
Copy link
Member

Thank you for contribution; looking forward for more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants