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
[FLINK-24409][kafka] Fix collection of KafkaSourceReaderMetrics for t… #17773
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit e53ad5e (Fri Nov 12 08:36:08 UTC 2021) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
&& tags.containsKey("partition") | ||
&& tags.get("partition").equals(String.valueOf(tp.partition())); | ||
&& tags.get("partition").equals(resolvedPartition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I know the reason of introducing local variables instead of change it directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think there is any good reason besides keeping the line a bit shorter.
// Validate pendingRecords | ||
for (int i = 0; i < NUM_RECORDS_PER_PARTITION; i++) { | ||
reader.fetch(); | ||
assertEquals(NUM_RECORDS_PER_PARTITION - i - 1, (long) pendingRecords.get().getValue()); | ||
Assertions.assertEquals( | ||
NUM_RECORDS_PER_PARTITION - i - 1, (long) pendingRecords.get().getValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: all the assert changes could be avoided by using static import. This will help reducing the review effort and minimise any unexpected human errors, e.g. typo.
topic1Name, true, true, KafkaSourceTestEnv::getRecordsForTopic); | ||
KafkaSourceTestEnv.setupTopic( | ||
topic2Name, true, true, KafkaSourceTestEnv::getRecordsForTopic); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it mean that the rest of the test works when topicSuffix.isEmpty() == true
for @EmptySource
and no topic has been created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the test essentially setups two additional topics if the suffix is specified. TOPIC1
and TOPIC2
are already set up in the setup
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. PTAL
topic1Name, true, true, KafkaSourceTestEnv::getRecordsForTopic); | ||
KafkaSourceTestEnv.setupTopic( | ||
topic2Name, true, true, KafkaSourceTestEnv::getRecordsForTopic); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the test essentially setups two additional topics if the suffix is specified. TOPIC1
and TOPIC2
are already set up in the setup
method.
&& tags.containsKey("partition") | ||
&& tags.get("partition").equals(String.valueOf(tp.partition())); | ||
&& tags.get("partition").equals(resolvedPartition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think there is any good reason besides keeping the line a bit shorter.
Thanks for your contribution, LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, is it also possible to fix https://github.com/apache/flink/pull/17773/files#diff-1b14f8cbd74aef6cdc991d1bef005bf0208d0a0a43d33807e13808550e82adc0R313 which is the log message is shown in the original ticket.
I believe it is MetricNames.PENDING_RECORDS
that would be reported incorrectly.
@mas-chen Thanks for the reminder but I am not sure which log message you are referring to. Unfortunately, the link you posted does not point to a line. |
…opics containing periods Internally, Kafka translates the periods in topic names to underscore. This led to that Flink could not collect the metrics and logged a warning. With this commit we also translate the topic name before trying to collect the metrics.
…opics containing periods
What is the purpose of the change
Internally, Kafka translates the periods in topic names to underscore.
This led to that Flink could not collect the metrics and logged a
warning. With this commit, we also translate the topic name before trying
to collect the metrics.
This PR subsumes #17401
Brief change log
Verifying this change
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (yes / no)Documentation