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

[HUDI-6313] Add metrics counters for compaction requested/completed events. #8759

Merged
merged 7 commits into from
Jun 20, 2023

Conversation

amrishlal
Copy link
Contributor

Change Logs

Add metrics counters for compaction start/stop events so that we can keep track of how many compactions were requested, how many finished, and how many produced error (interfered as number of starts - number of finished).

Impact

No user api for performance impact expected.

Risk level (write none, low medium or high below)

Low

Documentation Update

None

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@amrishlal amrishlal marked this pull request as ready for review May 18, 2023 21:33
@SteNicholas
Copy link
Member

@amrishlal, I don't think it's necessary to introduce the metrics in this pull request. The essence of demand in description is that monitor the different state of compaction action. Therefore, we should introduce different state metric of compaction action in state change phase.

Copy link
Contributor

@nsivabalan nsivabalan left a comment

Choose a reason for hiding this comment

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

1 minor comment

}

@Override
public HoodieWriteMetadata<HoodieData<WriteStatus>> execute() {
LOG.info("Compaction start.");
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this. or you added for debugging purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nsivabalan I added this based on our last discussion. It should help to get an idea of individual start / stop compaction events.

@nsivabalan
Copy link
Contributor

@SteNicholas : I get your intention. we did take a look at the active timeline methods where we do the transition. As of now, HoodieActive timeline is lightweight and does not have much dependency w/ other hudi entities as much as possible. we don't want to add dep to HoodieMetrics within Active timeline. Especially given we wanted to add this only for compaction. If demand arises that we want to emit this metric for all operations, we can think about it.
but for now, may be we can keep it one of and leave it as is. let us know what do you think.

@amrishlal
Copy link
Contributor Author

@SteNicholas Just pinging to see if you are ok with this PR based on @nsivabalan comments above?

@SteNicholas
Copy link
Member

SteNicholas commented May 24, 2023

@amrishlal, @nsivabalan, could the compaction.start and compaction.stop update to compaction.requested compaction.completed? compaction.stop make certain confusing to me.

@amrishlal
Copy link
Contributor Author

@amrishlal, @nsivabalan, could the compaction.start and compaction.stop update to compaction.requested compaction.completed? compaction.stop make certain confusing to me.

@SteNicholas Changed names to compaction.requested compaction.completed.

@SteNicholas
Copy link
Member

SteNicholas commented May 24, 2023

@amrishlal, could you add the test cause to verify whether the metric value is correct? Meanwhile, please change the title of this pull request to Add metrics counters for compaction requested/completed events.

@amrishlal amrishlal changed the title Add metrics counters for compaction start/stop events. Add metrics counters for compaction requested/completed events. May 24, 2023
@amrishlal
Copy link
Contributor Author

@amrishlal, could you add the test cause to verify whether the metric value is correct? Meanwhile, please change the title of this pull request to Add metrics counters for compaction requested/completed events.

@SteNicholas Can you point me to any similar test cases (where operational metrics are verified) that I can follow?

@SteNicholas
Copy link
Member

SteNicholas commented May 25, 2023

@amrishlal, you could follow TestHoodieMetrics to verify the introduced metrics. PTAL.
cc @nsivabalan

@amrishlal
Copy link
Contributor Author

@amrishlal, you could follow TestHoodieMetrics to verify the introduced metrics. PTAL. cc @nsivabalan

@SteNicholas I have added checks for compaction.requested and compaction.completed metrics as part of existing tests in TestHoodieCompactor.java

Copy link
Member

@SteNicholas SteNicholas left a comment

Choose a reason for hiding this comment

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

LGTM. cc @nsivabalan

@@ -48,10 +52,14 @@
public class RunCompactionActionExecutor<T> extends
BaseActionExecutor<T, HoodieData<HoodieRecord<T>>, HoodieData<HoodieKey>, HoodieData<WriteStatus>, HoodieWriteMetadata<HoodieData<WriteStatus>>> {

private static final Logger LOG = LoggerFactory.getLogger(LogCompactionExecutionHelper.class);

Copy link
Contributor

Choose a reason for hiding this comment

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

RunCompactionActionExecutor.class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

}

@Override
public HoodieWriteMetadata<HoodieData<WriteStatus>> execute() {
LOG.info("Compaction requested.");
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add the instant time for compaction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -116,6 +128,8 @@ public HoodieWriteMetadata<HoodieData<WriteStatus>> execute() {
throw new HoodieCompactionException("Could not compact " + config.getBasePath(), e);
}

LOG.info("Compaction completed.");
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add the instant time for compaction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -129,6 +152,10 @@ public void testCompactionEmpty() {
String compactionInstantTime = HoodieActiveTimeline.createNewInstantTime();
Option<HoodieCompactionPlan> plan = table.scheduleCompaction(context, compactionInstantTime, Option.empty());
assertFalse(plan.isPresent(), "If there is nothing to compact, result will be empty");

// Verify compaction.requested, compaction.completed metrics counts.
assertEquals(0, getCompactionMetricCount("counter", "compaction.requested"));
Copy link
Contributor

Choose a reason for hiding this comment

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

can we re-use the variables here instead of hard coding the metric names ?

Copy link
Contributor Author

@amrishlal amrishlal Jun 1, 2023

Choose a reason for hiding this comment

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

I can use const variables, but from what I could see referring to metric names using inline literal strings appears to be the common pattern in the codebase and hence this usage. Let me know what you think.

Copy link
Member

Choose a reason for hiding this comment

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

@amrishlal, you could use const variable REQUESTED_COMPACTION_EXTENSION in HoodieTimeline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SteNicholas Using HoodieTimeline.REQUESTED_COMPACTION_SUFFIX and HoodieTimeline.COMPLETED_COMPACTION_SUFFIX as REQUESTED_COMPACTION_EXTENSION was leading to a double dot in the final metric name.

@@ -180,6 +208,10 @@ public void testWriteStatusContentsAfterCompaction() throws Exception {
HoodieData<WriteStatus> result = compact(writeClient, compactionInstantTime);

verifyCompaction(result);

// Verify compaction.requested, compaction.completed metrics counts.
assertEquals(1, getCompactionMetricCount("counter", "compaction.requested"));
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

responded above.

@SteNicholas
Copy link
Member

@amrishlal, could you create a JIRA ticket or issue for this metric introduction? Meanwhile, you should update the title of this pull request, otherwise this pull request fails to validate.

@amrishlal amrishlal changed the title Add metrics counters for compaction requested/completed events. [HUDI-6313] Add metrics counters for compaction requested/completed events. Jun 2, 2023
@amrishlal
Copy link
Contributor Author

@amrishlal, could you create a JIRA ticket or issue for this metric introduction? Meanwhile, you should update the title of this pull request, otherwise this pull request fails to validate.

Done.

@hudi-bot
Copy link

CI report:

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

@nsivabalan nsivabalan merged commit 35897ba into apache:master Jun 20, 2023
44 checks passed
@amrishlal amrishlal deleted the add-compaction-metrics branch June 20, 2023 23:02
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.

None yet

4 participants