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

[FLINK-24409][kafka] Fix collection of KafkaSourceReaderMetrics for t… #17773

Merged
merged 2 commits into from Nov 17, 2021

Conversation

fapaul
Copy link

@fapaul fapaul commented Nov 12, 2021

…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

  • Translate the periods in topic names to underscore for metric collection

Verifying this change

  • Added a test to verify the log collection of a topic containing periods

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Nov 12, 2021

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@flinkbot
Copy link
Collaborator

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit e53ad5e (Fri Nov 12 08:36:08 UTC 2021)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

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 commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

&& tags.containsKey("partition")
&& tags.get("partition").equals(String.valueOf(tp.partition()));
&& tags.get("partition").equals(resolvedPartition);
Copy link
Contributor

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?

Copy link
Author

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());
Copy link
Contributor

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);
}
Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

got it, thanks!

Copy link
Author

@fapaul fapaul left a 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);
}
Copy link
Author

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);
Copy link
Author

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.

@JingGe
Copy link
Contributor

JingGe commented Nov 15, 2021

Thanks for your contribution, LGTM.

Copy link
Contributor

@mas-chen mas-chen left a 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.

@fapaul
Copy link
Author

fapaul commented Nov 16, 2021

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.

@mas-chen
Copy link
Contributor

@fapaul this is the one I am referring to:

Fabian Paul added 2 commits November 17, 2021 10:57
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants