Skip to content

Add filteredMsgCount for pulsar-admin broker-stats topics - #14531

Merged
codelipenghui merged 9 commits into
apache:masterfrom
tjiuming:dev/skipped_entries
Mar 15, 2022
Merged

codelipenghui merged 9 commits into
apache:masterfrom
tjiuming:dev/skipped_entries

Conversation

@tjiuming

@tjiuming tjiuming commented Mar 2, 2022 •

Copy link
Copy Markdown
Contributor

(If this PR fixes a github issue, please add Fixes #<xyz>.)
Fixes: #14507

Motivation

see master issue

Modifications

  1. add field msgFilteredCounter in AbstractTopic
  2. add methods addFilteredMsgCount, getMsgFilteredCount in AbstractTopic
  3. record filtered message count in AbstractBaseDispatcher#filterEntriesForConsumer

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

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

Check the box below or label this PR directly (if you have committer privilege).

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

  • doc-not-needed

@github-actions github-actions Bot added the doc-required Your PR changes impact docs and you will update later. label Mar 2, 2022
@tjiuming

tjiuming commented Mar 2, 2022 •

Copy link
Copy Markdown
Contributor Author

tests to be completed.

@github-actions

github-actions Bot commented Mar 2, 2022

Copy link
Copy Markdown

@tjiuming:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions github-actions Bot added doc-label-missing and removed doc-required Your PR changes impact docs and you will update later. doc-label-missing labels Mar 2, 2022
@github-actions

github-actions Bot commented Mar 2, 2022

Copy link
Copy Markdown

@tjiuming:Thanks for providing doc info!

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Mar 2, 2022
@codelipenghui codelipenghui added this to the 2.11.0 milestone Mar 2, 2022

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, please add tests.

subscription.acknowledgeMessage(entriesToFiltered, AckType.Individual,
Collections.emptyMap());

int filtered = entriesToFiltered.size();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's actually entry count, not message count. Please make it consist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

make sense, I'll change the field name. Thanks!

@gaoran10 gaoran10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

public void testFilteredMsgCount() throws Throwable{
String topic = "persistent://prop/ns-abc/topic" + UUID.randomUUID();
String subName = "sub";
Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING).topic(topic)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING).topic(topic)
@Cleanup
Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING).topic(topic)

EntryFilterWithClassLoader loader2 = spyWithClassAndConstructorArgs(EntryFilterWithClassLoader.class, filter2, narClassLoader);
field.set(dispatcher, ImmutableList.of(loader1, loader2));

Producer<String> producer = pulsarClient.newProducer(Schema.STRING)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
@Cleanup
Producer<String> producer = pulsarClient.newProducer(Schema.STRING)


int counter = 0;
while (true) {
Message<String> message = consumer.receive(1, TimeUnit.SECONDS);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 second might be too short in the CI environment if the broker dispatch messages slowly.

import org.apache.pulsar.broker.service.BrokerService;
import org.apache.pulsar.broker.service.BrokerTestBase;
import org.apache.pulsar.broker.service.Dispatcher;
import org.apache.pulsar.broker.service.*;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please avoid star import.

@dao-jun

dao-jun commented Mar 4, 2022

Copy link
Copy Markdown
Member

@codelipenghui changed, PTAL

@codelipenghui

Copy link
Copy Markdown
Contributor

/pulsarbot run-failure-checks

@codelipenghui
codelipenghui merged commit d3ccd4a into apache:master Mar 15, 2022
@codelipenghui codelipenghui changed the title [ISSUE] add filteredMsgCount for pulsar-admin topics stats Add filteredMsgCount for pulsar-admin topics stats Mar 15, 2022
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
eolivelli pushed a commit that referenced this pull request Apr 29, 2022
eolivelli pushed a commit to eolivelli/pulsar that referenced this pull request Apr 29, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request May 9, 2022
(cherry picked from commit d3ccd4a)
(cherry picked from commit ce89b53)
@tjiuming
tjiuming deleted the dev/skipped_entries branch May 10, 2022 07:00
@michaeljmarshall

Copy link
Copy Markdown
Member

@tjiuming - thank you for adding these stats. Would you be able to add the documentation to the admin api docs https://pulsar.apache.org/docs/next/admin-api-topics#get-stats?

@michaeljmarshall michaeljmarshall changed the title Add filteredMsgCount for pulsar-admin topics stats Add filteredMsgCount for pulsar-admin broker-stats topics Jul 29, 2022
@michaeljmarshall

Copy link
Copy Markdown
Member

Note that this PR did not add these metrics to the pulsar-admin topics stats command. It added it to the pulsar-admin broker-stats topics command. It would be helpful to expose these metrics on the topics stats command as subscription level metrics. It'd also be nice to add it as the prometheus metrics output.

@tjiuming

Copy link
Copy Markdown
Contributor Author

Note that this PR did not add these metrics to the pulsar-admin topics stats command. It added it to the pulsar-admin broker-stats topics command. It would be helpful to expose these metrics on the topics stats command as subscription level metrics. It'd also be nice to add it as the prometheus metrics output.

All right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/broker area/metrics doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add metrics for the skipped entries count

6 participants