-
Notifications
You must be signed in to change notification settings - Fork 749
[GOBBLIN-1934] Monitor High Level Consumer queue size #3805
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
Changes from 3 commits
1187b4a
298b912
206692d
2963aa6
214c054
5e85cbb
b5a2dba
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 |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| import java.util.concurrent.TimeUnit; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
||
| import java.util.concurrent.atomic.AtomicIntegerArray; | ||
| import org.apache.commons.lang3.reflect.ConstructorUtils; | ||
|
|
||
| import com.codahale.metrics.Counter; | ||
|
|
@@ -51,6 +52,7 @@ | |
| import org.apache.gobblin.kafka.client.GobblinConsumerRebalanceListener; | ||
| import org.apache.gobblin.kafka.client.GobblinKafkaConsumerClient; | ||
| import org.apache.gobblin.kafka.client.KafkaConsumerRecord; | ||
| import org.apache.gobblin.metrics.ContextAwareGauge; | ||
| import org.apache.gobblin.metrics.MetricContext; | ||
| import org.apache.gobblin.metrics.Tag; | ||
| import org.apache.gobblin.runtime.metrics.RuntimeMetrics; | ||
|
|
@@ -87,7 +89,7 @@ public abstract class HighLevelConsumer<K,V> extends AbstractIdleService { | |
| @Getter | ||
| protected final String topic; | ||
| protected final Config config; | ||
| private final int numThreads; | ||
| protected final int numThreads; | ||
|
|
||
| /** | ||
| * {@link MetricContext} for the consumer. Note this is instantiated when {@link #startUp()} is called, so | ||
|
|
@@ -100,7 +102,8 @@ public abstract class HighLevelConsumer<K,V> extends AbstractIdleService { | |
| private final GobblinKafkaConsumerClient gobblinKafkaConsumerClient; | ||
| private final ScheduledExecutorService consumerExecutor; | ||
| private final ExecutorService queueExecutor; | ||
| private final BlockingQueue[] queues; | ||
| protected final BlockingQueue[] queues; | ||
| protected ContextAwareGauge[] queueSizeGauges; | ||
| private final AtomicInteger recordsProcessed; | ||
| private final Map<KafkaPartition, Long> partitionOffsetsToCommit; | ||
| private final boolean enableAutoCommit; | ||
|
|
@@ -197,6 +200,14 @@ protected void shutdownMetrics() throws IOException { | |
| */ | ||
| protected void createMetrics() { | ||
| this.messagesRead = this.metricContext.counter(RuntimeMetrics.GOBBLIN_KAFKA_HIGH_LEVEL_CONSUMER_MESSAGES_READ); | ||
| this.queueSizeGauges = new ContextAwareGauge[numThreads]; | ||
| for (int i=0; i < numThreads; i++) { | ||
|
umustafi marked this conversation as resolved.
Outdated
Contributor
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. oops, one more |
||
| // An 'effectively' final variable is needed inside the lambda expression below | ||
| int finalI = i; | ||
|
umustafi marked this conversation as resolved.
|
||
| this.queueSizeGauges[i] = this.metricContext.newContextAwareGauge( | ||
| RuntimeMetrics.GOBBLIN_KAFKA_HIGH_LEVEL_CONSUMER_QUEUE_SIZE_PREFIX + "-" + i, | ||
| () -> queues[finalI].size()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -237,6 +248,7 @@ protected void startUp() { | |
| private void consume() { | ||
| try { | ||
| Iterator<KafkaConsumerRecord> itr = gobblinKafkaConsumerClient.consume(); | ||
| // TODO: we may be committing too early and only want to commit after process messages | ||
| if(!enableAutoCommit) { | ||
| commitOffsets(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,12 +29,12 @@ | |
| import com.typesafe.config.Config; | ||
| import com.typesafe.config.ConfigValueFactory; | ||
|
|
||
| import java.util.concurrent.atomic.AtomicIntegerArray; | ||
|
umustafi marked this conversation as resolved.
Outdated
|
||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| import org.apache.gobblin.kafka.client.DecodeableKafkaRecord; | ||
| import org.apache.gobblin.metrics.ContextAwareGauge; | ||
| import org.apache.gobblin.metrics.ContextAwareMeter; | ||
| import org.apache.gobblin.metrics.ServiceMetricNames; | ||
| import org.apache.gobblin.runtime.api.DagActionStore; | ||
| import org.apache.gobblin.runtime.api.FlowSpec; | ||
| import org.apache.gobblin.runtime.api.SpecNotFoundException; | ||
|
|
@@ -217,7 +217,16 @@ protected void submitFlowToDagManagerHelper(String flowGroup, String flowName) { | |
|
|
||
| @Override | ||
| protected void createMetrics() { | ||
| super.messagesRead = this.getMetricContext().counter(ServiceMetricNames.GOBBLIN_SERVICE_PREFIX + RuntimeMetrics.GOBBLIN_KAFKA_HIGH_LEVEL_CONSUMER_MESSAGES_READ); | ||
| super.messagesRead = this.getMetricContext().counter(RuntimeMetrics.DAG_ACTION_STORE_MONITOR_PREFIX + "." + RuntimeMetrics.GOBBLIN_KAFKA_HIGH_LEVEL_CONSUMER_MESSAGES_READ); | ||
| super.queueSizeGauges = new ContextAwareGauge[super.numThreads]; | ||
| for (int i=0; i < numThreads; i++) { | ||
| // An 'effectively' final variable is needed inside the lambda expression below | ||
| int finalI = i; | ||
| this.queueSizeGauges[i] = this.getMetricContext().newContextAwareGauge( | ||
| RuntimeMetrics.GOBBLIN_KAFKA_HIGH_LEVEL_CONSUMER_QUEUE_SIZE_PREFIX + "-" + i, | ||
| () -> super.queues[finalI].size()); | ||
| } | ||
|
Contributor
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 may not be clicking for me... but why can't this all be replaced by
Contributor
Author
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. Oh oops I overwrote the important piece of the code, but I need to add the |
||
| // Dag Action specific metrics | ||
| 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.flowsLaunched = this.getMetricContext().contextAwareMeter(RuntimeMetrics.GOBBLIN_DAG_ACTION_STORE_MONITOR_FLOWS_LAUNCHED); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.