-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
@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. |
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.
1 minor comment
} | ||
|
||
@Override | ||
public HoodieWriteMetadata<HoodieData<WriteStatus>> execute() { | ||
LOG.info("Compaction start."); |
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.
do we need this. or you added for debugging purpose?
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.
@nsivabalan I added this based on our last discussion. It should help to get an idea of individual start / stop compaction events.
@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. |
@SteNicholas Just pinging to see if you are ok with this PR based on @nsivabalan comments above? |
@amrishlal, @nsivabalan, could the |
@SteNicholas Changed names to |
@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 |
@SteNicholas Can you point me to any similar test cases (where operational metrics are verified) that I can follow? |
@amrishlal, you could follow |
… compaction test case.
@SteNicholas I have added checks for |
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. 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); | |||
|
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.
RunCompactionActionExecutor.class
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.
Fixed.
} | ||
|
||
@Override | ||
public HoodieWriteMetadata<HoodieData<WriteStatus>> execute() { | ||
LOG.info("Compaction requested."); |
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.
can we add the instant time for compaction
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.
Done.
@@ -116,6 +128,8 @@ public HoodieWriteMetadata<HoodieData<WriteStatus>> execute() { | |||
throw new HoodieCompactionException("Could not compact " + config.getBasePath(), e); | |||
} | |||
|
|||
LOG.info("Compaction completed."); |
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.
can we add the instant time for compaction
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.
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")); |
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.
can we re-use the variables here instead of hard coding the metric names ?
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 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.
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.
@amrishlal, you could use const variable REQUESTED_COMPACTION_EXTENSION
in HoodieTimeline
.
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.
@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")); |
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.
same here
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.
responded above.
@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. |
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