-
Notifications
You must be signed in to change notification settings - Fork 751
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
[GOBBLIN-1736] Add metrics for change stream monitor and mysql quota manager #3593
Changes from 7 commits
70afb49
bd0fbe1
f13e6ea
d6871dc
6da862d
c082709
6b4b3a4
acc9ad2
a3dbb21
dc36080
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
|
||
package org.apache.gobblin.service.modules.orchestration; | ||
|
||
import com.codahale.metrics.Meter; | ||
import com.codahale.metrics.Timer; | ||
import java.io.IOException; | ||
import java.sql.Connection; | ||
import java.sql.PreparedStatement; | ||
|
@@ -38,6 +40,7 @@ | |
import org.apache.gobblin.configuration.ConfigurationKeys; | ||
import org.apache.gobblin.exception.QuotaExceededException; | ||
import org.apache.gobblin.metastore.MysqlStateStore; | ||
import org.apache.gobblin.runtime.metrics.RuntimeMetrics; | ||
import org.apache.gobblin.service.ServiceConfigKeys; | ||
import org.apache.gobblin.service.modules.flowgraph.Dag; | ||
import org.apache.gobblin.service.modules.spec.JobExecutionPlan; | ||
|
@@ -52,13 +55,17 @@ | |
public class MysqlUserQuotaManager extends AbstractUserQuotaManager { | ||
public final MysqlQuotaStore quotaStore; | ||
public final RunningDagIdsStore runningDagIds; | ||
private Meter quotaExceedsRequests; | ||
private Meter failedQuotaCheck; | ||
|
||
|
||
@Inject | ||
public MysqlUserQuotaManager(Config config) throws IOException { | ||
super(config); | ||
this.quotaStore = createQuotaStore(config); | ||
this.runningDagIds = createRunningDagStore(config); | ||
this.failedQuotaCheck = this.metricContext.contextAwareMeter(RuntimeMetrics.GOBBLIN_MYSQL_QUOTA_MANAGER_UNEXPECTED_ERRORS); | ||
this.quotaExceedsRequests = this.metricContext.contextAwareMeter(RuntimeMetrics.GOBBLIN_MYSQL_QUOTA_MANAGER_QUOTA_EXCEEDS_REQUESTS); | ||
} | ||
|
||
void addDagId(Connection connection, String dagId) throws IOException { | ||
|
@@ -80,18 +87,21 @@ public void init(Collection<Dag<JobExecutionPlan>> dags) { | |
|
||
@Override | ||
public void checkQuota(Collection<Dag.DagNode<JobExecutionPlan>> dagNodes) throws IOException { | ||
try (Connection connection = this.quotaStore.dataSource.getConnection()) { | ||
try (Connection connection = this.quotaStore.dataSource.getConnection(); | ||
Timer.Context context = metricContext.timer(RuntimeMetrics.GOBBLIN_MYSQL_QUOTA_MANAGER_CHECK_QUOTA_TIME).time()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when do we call stop for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in try clause, when this try section finish, the context will close automatically |
||
connection.setAutoCommit(false); | ||
|
||
for (Dag.DagNode<JobExecutionPlan> dagNode : dagNodes) { | ||
QuotaCheck quotaCheck = increaseAndCheckQuota(connection, dagNode); | ||
if ((!quotaCheck.proxyUserCheck || !quotaCheck.requesterCheck || !quotaCheck.flowGroupCheck)) { | ||
connection.rollback(); | ||
quotaExceedsRequests.mark(); | ||
throw new QuotaExceededException(quotaCheck.requesterMessage); | ||
} | ||
} | ||
connection.commit(); | ||
} catch (SQLException e) { | ||
this.failedQuotaCheck.mark(); | ||
throw new IOException(e); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
package org.apache.gobblin.service.monitoring; | ||
|
||
import com.codahale.metrics.Meter; | ||
import java.io.IOException; | ||
import java.sql.SQLException; | ||
import java.util.UUID; | ||
|
@@ -50,9 +51,10 @@ public class DagActionStoreChangeMonitor extends HighLevelConsumer { | |
public static final String DAG_ACTION_CHANGE_MONITOR_PREFIX = "dagActionChangeStore"; | ||
|
||
// Metrics | ||
ContextAwareMeter killsInvoked; | ||
ContextAwareMeter resumesInvoked; | ||
ContextAwareMeter unexpectedErrors; | ||
private ContextAwareMeter killsInvoked; | ||
private ContextAwareMeter resumesInvoked; | ||
private ContextAwareMeter unexpectedErrors; | ||
private Meter messageProcessedMeter; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do you use normal |
||
|
||
protected CacheLoader<String, String> cacheLoader = new CacheLoader<String, String>() { | ||
@Override | ||
|
@@ -92,7 +94,8 @@ protected void assignTopicPartitions() { | |
partitioned and processed by only one thread (and corresponding queue). | ||
*/ | ||
protected void processMessage(DecodeableKafkaRecord message) { | ||
// TODO: Add metric that service is healthy and we're continuously processing messages. | ||
// This will also include the heathCheck message so that we can rely on this to monitor the health of this Monitor | ||
messageProcessedMeter.mark(); | ||
String key = (String) message.getKey(); | ||
DagActionStoreChangeEvent value = (DagActionStoreChangeEvent) message.getValue(); | ||
|
||
|
@@ -171,6 +174,7 @@ protected void createMetrics() { | |
this.killsInvoked = this.getMetricContext().contextAwareMeter(RuntimeMetrics.GOBBLIN_DAG_ACTION_STORE_MONITOR_KILLS_INVOKED); | ||
this.resumesInvoked = this.getMetricContext().contextAwareMeter(RuntimeMetrics.GOBBLIN_DAG_ACTION_STORE_MONITOR_RESUMES_INVOKED); | ||
this.unexpectedErrors = this.getMetricContext().contextAwareMeter(RuntimeMetrics.GOBBLIN_DAG_ACTION_STORE_MONITOR_UNEXPECTED_ERRORS); | ||
this.messageProcessedMeter = this.getMetricContext().contextAwareMeter(RuntimeMetrics.GOBBLIN_DAG_ACTION_STORE_MONITOR_MESSAGE_PROCESSED); | ||
} | ||
|
||
} |
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.
Names are a bit hard to understand without reading the code
GOBBLIN_MYSQL_QUOTA_MANAGER_QUOTA_REQUESTS_EXCEEDED
so it implies number of requests exceeding quota.gobblin_mysql_quota_manager_time_to_check_quota
for the second, is it measuring amount of time it takes to do the whole check?