public Metrics(MetricContext context) { this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_QUEUE_SIZE, ()->StreamingKafkaSpecConsumer.this._jobSpecQueue.size())); this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_ENQ, ()->jobSpecEnqCount.get())); this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_DEQ, ()->jobSpecDeqCount.get())); this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_CONSUMED, ()->getNewSpecs() + getRemovedSpecs() + getMessageParseFailures())); this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_PARSE_FAILURES, ()->getMessageParseFailures())); }
public GobblinHelixJobSchedulerMetrics (final ExecutorService jobExecutor, final MetricContext metricContext, int windowSizeInMin) { this.timeBeforeJobScheduling = metricContext.contextAwareTimer(TIMER_BEFORE_JOB_SCHEDULING, windowSizeInMin, TimeUnit.MINUTES); this.timeBeforeJobLaunching = metricContext.contextAwareTimer(TIMER_BEFORE_JOB_LAUNCHING, windowSizeInMin, TimeUnit.MINUTES); this.timeBetwenJobSchedulingAndLaunching = metricContext.contextAwareTimer(TIMER_BETWEEN_JOB_SCHEDULING_AND_LAUNCHING, windowSizeInMin, TimeUnit.MINUTES); this.numCancellationStart = new AtomicLong(0); this.numCancellationComplete = new AtomicLong(0); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(SCHEDULE_CANCELLATION_START, ()->this.numCancellationStart.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(SCHEDULE_CANCELLATION_END, ()->this.numCancellationComplete.get())); this.contextAwareMetrics.add(timeBeforeJobScheduling); this.contextAwareMetrics.add(timeBeforeJobLaunching); this.contextAwareMetrics.add(timeBetwenJobSchedulingAndLaunching); this.threadPoolExecutor = (ThreadPoolExecutor) jobExecutor; // executor metrics this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_ACTIVE_COUNT, ()->this.threadPoolExecutor.getActiveCount())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_MAX_POOL_SIZE, ()->this.threadPoolExecutor.getMaximumPoolSize())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_POOL_SIZE, ()->this.threadPoolExecutor.getPoolSize())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_CORE_POOL_SIZE, ()->this.threadPoolExecutor.getCorePoolSize())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_QUEUE_SIZE, ()->this.threadPoolExecutor.getQueue().size())); }
public StandardMetrics(final JobCatalog jobCatalog, Optional<Config> sysConfig) { // timer window size this.timeWindowSizeInMinutes = sysConfig.isPresent()? ConfigUtils.getInt(sysConfig.get(), ConfigurationKeys.METRIC_TIMER_WINDOW_SIZE_IN_MINUTES, ConfigurationKeys.DEFAULT_METRIC_TIMER_WINDOW_SIZE_IN_MINUTES) : ConfigurationKeys.DEFAULT_METRIC_TIMER_WINDOW_SIZE_IN_MINUTES; this.metricsContext = jobCatalog.getMetricContext(); this.totalAddedJobs = new AtomicLong(0); this.totalDeletedJobs = new AtomicLong(0); this.totalUpdatedJobs = new AtomicLong(0); this.timeForJobCatalogGet = metricsContext.contextAwareTimer(TIME_FOR_JOB_CATALOG_GET, timeWindowSizeInMinutes, TimeUnit.MINUTES); this.totalAddCalls = metricsContext.newContextAwareGauge(TOTAL_ADD_CALLS, ()->this.totalAddedJobs.get()); this.totalUpdateCalls = metricsContext.newContextAwareGauge(TOTAL_UPDATE_CALLS, ()->this.totalUpdatedJobs.get()); this.totalDeleteCalls = metricsContext.newContextAwareGauge(TOTAL_DELETE_CALLS, ()->this.totalDeletedJobs.get()); this.numActiveJobs = metricsContext.newContextAwareGauge(NUM_ACTIVE_JOBS_NAME, ()->(int)(totalAddedJobs.get() - totalDeletedJobs.get())); this.contextAwareMetrics.add(timeForJobCatalogGet); this.contextAwareMetrics.add(totalAddCalls); this.contextAwareMetrics.add(totalDeleteCalls); this.contextAwareMetrics.add(totalUpdateCalls); this.contextAwareMetrics.add(numActiveJobs); }
public GobblinHelixJobLauncherMetrics(String metricsName, final MetricContext metricContext, int windowSizeInMin) { this.metricsName = metricsName; // All historical counters this.totalJobsLaunched = new AtomicLong(0); this.totalJobsCompleted = new AtomicLong(0); this.totalJobsCommitted = new AtomicLong(0); this.totalJobsFailed = new AtomicLong(0); this.totalJobsCancelled = new AtomicLong(0); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_LAUNCHED, ()->this.totalJobsLaunched.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_COMPLETED, ()->this.totalJobsCompleted.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_COMMITTED, ()->this.totalJobsCommitted.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_FAILED, ()->this.totalJobsFailed.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_CANCELLED, ()->this.totalJobsCancelled.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_RUNNING, ()->(int)(GobblinHelixJobLauncherMetrics.this.totalJobsLaunched.get() - GobblinHelixJobLauncherMetrics.this.totalJobsCompleted.get()))); this.timeForCompletedJobs = metricContext.contextAwareTimer(JobExecutionLauncher.StandardMetrics.TIMER_FOR_COMPLETED_JOBS, windowSizeInMin, TimeUnit.MINUTES); this.timeForFailedJobs = metricContext.contextAwareTimer(JobExecutionLauncher.StandardMetrics.TIMER_FOR_FAILED_JOBS, windowSizeInMin, TimeUnit.MINUTES); this.timeForCommittedJobs = metricContext.contextAwareTimer(JobExecutionLauncher.StandardMetrics.TIMER_FOR_COMMITTED_JOBS, windowSizeInMin, TimeUnit.MINUTES); this.contextAwareMetrics.add(timeForCommittedJobs); this.contextAwareMetrics.add(timeForCompletedJobs); this.contextAwareMetrics.add(timeForFailedJobs); }
public TaskExecutionMetrics (TaskExecutor executor, MetricContext context) { taskExecutor = executor; contextAwareMetrics.add(context.newContextAwareGauge(CURRENT_QUEUED_TASK_COUNT, ()->this.taskExecutor.getCurrentQueuedTaskCount().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(CURRENT_QUEUED_TASK_TOTAL_TIME, ()->this.taskExecutor.getCurrentQueuedTaskTotalTime().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(HISTORICAL_QUEUED_TASK_COUNT, ()->this.taskExecutor.getHistoricalQueuedTaskCount().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(HISTORICAL_QUEUED_TASK_TOTAL_TIME, ()->this.taskExecutor.getHistoricalQueuedTaskTotalTime().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(QUEUED_TASK_COUNT, ()->this.taskExecutor.getQueuedTaskCount().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(QUEUED_TASK_TOTAL_TIME, ()->this.taskExecutor.getQueuedTaskTotalTime().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(FAILED_TASK_COUNT, ()->this.taskExecutor.getFailedTaskCount().getCount())); contextAwareMetrics.add(context.newContextAwareGauge(SUCCESSFUL_TASK_COUNT, ()->this.taskExecutor.getSuccessfulTaskCount().getCount())); contextAwareMetrics.add(context.newContextAwareGauge(RUNNING_TASK_COUNT, ()->this.taskExecutor.getRunningTaskCount().getCount())); this.rawMetrics.put(ConfigurationKeys.WORK_UNIT_CREATION_AND_RUN_INTERVAL, this.taskExecutor.getTaskCreateAndRunTimer()); }
public StandardMetrics(final SpecCatalog specCatalog, Optional<Config> sysConfig) { this.timeWindowSizeInMinutes = sysConfig.isPresent()? ConfigUtils.getInt(sysConfig.get(), ConfigurationKeys.METRIC_TIMER_WINDOW_SIZE_IN_MINUTES, ConfigurationKeys.DEFAULT_METRIC_TIMER_WINDOW_SIZE_IN_MINUTES) : ConfigurationKeys.DEFAULT_METRIC_TIMER_WINDOW_SIZE_IN_MINUTES; this.metricsContext = specCatalog.getMetricContext(); this.timeForSpecCatalogGet = metricsContext.contextAwareTimer(TIME_FOR_SPEC_CATALOG_GET, timeWindowSizeInMinutes, TimeUnit.MINUTES); this.totalAddedSpecs = new AtomicLong(0); this.totalDeletedSpecs = new AtomicLong(0); this.totalUpdatedSpecs = new AtomicLong(0); this.numActiveSpecs = metricsContext.newContextAwareGauge(NUM_ACTIVE_SPECS_NAME, ()->{ long startTime = System.currentTimeMillis(); int size = specCatalog.getSpecs().size(); updateGetSpecTime(startTime); return size; }); this.totalAddCalls = metricsContext.newContextAwareGauge(TOTAL_ADD_CALLS, ()->this.totalAddedSpecs.get()); this.totalUpdateCalls = metricsContext.newContextAwareGauge(TOTAL_UPDATE_CALLS, ()->this.totalUpdatedSpecs.get()); this.totalDeleteCalls = metricsContext.newContextAwareGauge(TOTAL_DELETE_CALLS, ()->this.totalDeletedSpecs.get()); this.contextAwareMetrics.add(numActiveSpecs); this.contextAwareMetrics.add(totalAddCalls); this.contextAwareMetrics.add(totalUpdateCalls); this.contextAwareMetrics.add(totalDeleteCalls); this.contextAwareMetrics.add(timeForSpecCatalogGet); }
public GobblinHelixPlanningJobLauncherMetrics(String metricsName, final MetricContext metricContext, int windowSizeInMin, HelixJobsMapping jobsMapping) { this.metricsName = metricsName; this.jobsMapping = jobsMapping; this.timeForCompletedPlanningJobs = metricContext.contextAwareTimer(TIMER_FOR_COMPLETED_PLANNING_JOBS, windowSizeInMin, TimeUnit.MINUTES); this.timeForFailedPlanningJobs = metricContext.contextAwareTimer(TIMER_FOR_FAILED_PLANNING_JOBS, windowSizeInMin, TimeUnit.MINUTES); this.numActivePlanningJobs = metricContext.newContextAwareGauge(NUM_ACTIVE_PLANNING_JOBS, ()->getNumOfMappings()); this.contextAwareMetrics.add(timeForCompletedPlanningJobs); this.contextAwareMetrics.add(timeForFailedPlanningJobs); this.contextAwareMetrics.add(numActivePlanningJobs); }
public StandardMetrics(final GobblinInstanceDriver parent) { this.uptimeMs = parent.getMetricContext().newContextAwareGauge(UPTIMEMS_NAME, new Gauge<Long>() { @Override public Long getValue() { return startTimeMs > 0 ? System.currentTimeMillis() - startTimeMs : 0; } }); this.upFlag = parent.getMetricContext().newContextAwareGauge(UPFLAG_NAME, new Gauge<Integer>() { @Override public Integer getValue() { switch (parent.state()) { case RUNNING: return 1; case FAILED: return -1; default: return 0; } } }); this.numUnclassifiedErrors = parent.getMetricContext().contextAwareCounter(NUM_UNCLASSIFIED_ERRORS_NAME); parent.addListener(this, new Executor() { @Override public void execute(Runnable command) { command.run(); } }); }
@Test public void testTaggableGauge() { ContextAwareGauge<Long> queueSize = this.context.newContextAwareGauge( QUEUE_SIZE, new Gauge<Long>() { @Override public Long getValue() { return 1000l; } }); this.context.register(QUEUE_SIZE, queueSize); Assert.assertEquals(queueSize.getValue().longValue(), 1000l); Assert.assertEquals( this.context.getGauges().get(queueSize.getName()), queueSize.getInnerMetric()); Assert.assertEquals(queueSize.getContext(), this.context); Assert.assertEquals(queueSize.getName(), QUEUE_SIZE); }
metricContext.newContextAwareGauge("com.linkedin.example.gauge", new Gauge<Long>() { @Override public Long getValue() {
metricContext.newContextAwareGauge("com.linkedin.example.gauge", new Gauge<Long>() { @Override public Long getValue() {
public StandardMetrics(final JobExecutionLauncher parent) { this.numJobsLaunched = parent.getMetricContext().contextAwareCounter(NUM_JOBS_LAUNCHED); this.numJobsCompleted = parent.getMetricContext().contextAwareCounter(NUM_JOBS_COMPLETED); this.numJobsCommitted = parent.getMetricContext().contextAwareCounter(NUM_JOBS_COMMITTED); this.numJobsFailed = parent.getMetricContext().contextAwareCounter(NUM_JOBS_FAILED); this.numJobsCancelled = parent.getMetricContext().contextAwareCounter(NUM_JOBS_CANCELLED); this.numJobsRunning = parent.getMetricContext().newContextAwareGauge(NUM_JOBS_RUNNING, new Gauge<Integer>() { @Override public Integer getValue() { return (int)(StandardMetrics.this.getNumJobsLaunched().getCount() - StandardMetrics.this.getNumJobsCompleted().getCount() - StandardMetrics.this.getNumJobsCancelled().getCount()); } }); } }
public Metrics(MetricContext context) { this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_QUEUE_SIZE, ()->StreamingKafkaSpecConsumer.this._jobSpecQueue.size())); this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_ENQ, ()->jobSpecEnqCount.get())); this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_DEQ, ()->jobSpecDeqCount.get())); this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_CONSUMED, ()->getNewSpecs() + getRemovedSpecs() + getMessageParseFailures())); this.contextAwareMetrics.add(context.newContextAwareGauge(SPEC_CONSUMER_JOB_SPEC_PARSE_FAILURES, ()->getMessageParseFailures())); }
public GobblinHelixJobSchedulerMetrics (final ExecutorService jobExecutor, final MetricContext metricContext, int windowSizeInMin) { this.timeBeforeJobScheduling = metricContext.contextAwareTimer(TIMER_BEFORE_JOB_SCHEDULING, windowSizeInMin, TimeUnit.MINUTES); this.timeBeforeJobLaunching = metricContext.contextAwareTimer(TIMER_BEFORE_JOB_LAUNCHING, windowSizeInMin, TimeUnit.MINUTES); this.timeBetwenJobSchedulingAndLaunching = metricContext.contextAwareTimer(TIMER_BETWEEN_JOB_SCHEDULING_AND_LAUNCHING, windowSizeInMin, TimeUnit.MINUTES); this.numCancellationStart = new AtomicLong(0); this.numCancellationComplete = new AtomicLong(0); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(SCHEDULE_CANCELLATION_START, ()->this.numCancellationStart.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(SCHEDULE_CANCELLATION_END, ()->this.numCancellationComplete.get())); this.contextAwareMetrics.add(timeBeforeJobScheduling); this.contextAwareMetrics.add(timeBeforeJobLaunching); this.contextAwareMetrics.add(timeBetwenJobSchedulingAndLaunching); this.threadPoolExecutor = (ThreadPoolExecutor) jobExecutor; // executor metrics this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_ACTIVE_COUNT, ()->this.threadPoolExecutor.getActiveCount())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_MAX_POOL_SIZE, ()->this.threadPoolExecutor.getMaximumPoolSize())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_POOL_SIZE, ()->this.threadPoolExecutor.getPoolSize())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_CORE_POOL_SIZE, ()->this.threadPoolExecutor.getCorePoolSize())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.EXECUTOR_QUEUE_SIZE, ()->this.threadPoolExecutor.getQueue().size())); }
public GobblinHelixJobLauncherMetrics(String metricsName, final MetricContext metricContext, int windowSizeInMin) { this.metricsName = metricsName; // All historical counters this.totalJobsLaunched = new AtomicLong(0); this.totalJobsCompleted = new AtomicLong(0); this.totalJobsCommitted = new AtomicLong(0); this.totalJobsFailed = new AtomicLong(0); this.totalJobsCancelled = new AtomicLong(0); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_LAUNCHED, ()->this.totalJobsLaunched.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_COMPLETED, ()->this.totalJobsCompleted.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_COMMITTED, ()->this.totalJobsCommitted.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_FAILED, ()->this.totalJobsFailed.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_CANCELLED, ()->this.totalJobsCancelled.get())); this.contextAwareMetrics.add(metricContext.newContextAwareGauge(JobExecutionLauncher.StandardMetrics.NUM_JOBS_RUNNING, ()->(int)(GobblinHelixJobLauncherMetrics.this.totalJobsLaunched.get() - GobblinHelixJobLauncherMetrics.this.totalJobsCompleted.get()))); this.timeForCompletedJobs = metricContext.contextAwareTimer(JobExecutionLauncher.StandardMetrics.TIMER_FOR_COMPLETED_JOBS, windowSizeInMin, TimeUnit.MINUTES); this.timeForFailedJobs = metricContext.contextAwareTimer(JobExecutionLauncher.StandardMetrics.TIMER_FOR_FAILED_JOBS, windowSizeInMin, TimeUnit.MINUTES); this.timeForCommittedJobs = metricContext.contextAwareTimer(JobExecutionLauncher.StandardMetrics.TIMER_FOR_COMMITTED_JOBS, windowSizeInMin, TimeUnit.MINUTES); this.contextAwareMetrics.add(timeForCommittedJobs); this.contextAwareMetrics.add(timeForCompletedJobs); this.contextAwareMetrics.add(timeForFailedJobs); }
public StandardMetrics(final JobCatalog jobCatalog, Optional<Config> sysConfig) { // timer window size this.timeWindowSizeInMinutes = sysConfig.isPresent()? ConfigUtils.getInt(sysConfig.get(), ConfigurationKeys.METRIC_TIMER_WINDOW_SIZE_IN_MINUTES, ConfigurationKeys.DEFAULT_METRIC_TIMER_WINDOW_SIZE_IN_MINUTES) : ConfigurationKeys.DEFAULT_METRIC_TIMER_WINDOW_SIZE_IN_MINUTES; this.metricsContext = jobCatalog.getMetricContext(); this.totalAddedJobs = new AtomicLong(0); this.totalDeletedJobs = new AtomicLong(0); this.totalUpdatedJobs = new AtomicLong(0); this.timeForJobCatalogGet = metricsContext.contextAwareTimer(TIME_FOR_JOB_CATALOG_GET, timeWindowSizeInMinutes, TimeUnit.MINUTES); this.totalAddCalls = metricsContext.newContextAwareGauge(TOTAL_ADD_CALLS, ()->this.totalAddedJobs.get()); this.totalUpdateCalls = metricsContext.newContextAwareGauge(TOTAL_UPDATE_CALLS, ()->this.totalUpdatedJobs.get()); this.totalDeleteCalls = metricsContext.newContextAwareGauge(TOTAL_DELETE_CALLS, ()->this.totalDeletedJobs.get()); this.numActiveJobs = metricsContext.newContextAwareGauge(NUM_ACTIVE_JOBS_NAME, ()->(int)(totalAddedJobs.get() - totalDeletedJobs.get())); this.contextAwareMetrics.add(timeForJobCatalogGet); this.contextAwareMetrics.add(totalAddCalls); this.contextAwareMetrics.add(totalDeleteCalls); this.contextAwareMetrics.add(totalUpdateCalls); this.contextAwareMetrics.add(numActiveJobs); }
public TaskExecutionMetrics (TaskExecutor executor, MetricContext context) { taskExecutor = executor; contextAwareMetrics.add(context.newContextAwareGauge(CURRENT_QUEUED_TASK_COUNT, ()->this.taskExecutor.getCurrentQueuedTaskCount().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(CURRENT_QUEUED_TASK_TOTAL_TIME, ()->this.taskExecutor.getCurrentQueuedTaskTotalTime().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(HISTORICAL_QUEUED_TASK_COUNT, ()->this.taskExecutor.getHistoricalQueuedTaskCount().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(HISTORICAL_QUEUED_TASK_TOTAL_TIME, ()->this.taskExecutor.getHistoricalQueuedTaskTotalTime().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(QUEUED_TASK_COUNT, ()->this.taskExecutor.getQueuedTaskCount().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(QUEUED_TASK_TOTAL_TIME, ()->this.taskExecutor.getQueuedTaskTotalTime().longValue())); contextAwareMetrics.add(context.newContextAwareGauge(FAILED_TASK_COUNT, ()->this.taskExecutor.getFailedTaskCount().getCount())); contextAwareMetrics.add(context.newContextAwareGauge(SUCCESSFUL_TASK_COUNT, ()->this.taskExecutor.getSuccessfulTaskCount().getCount())); contextAwareMetrics.add(context.newContextAwareGauge(RUNNING_TASK_COUNT, ()->this.taskExecutor.getRunningTaskCount().getCount())); this.rawMetrics.put(ConfigurationKeys.WORK_UNIT_CREATION_AND_RUN_INTERVAL, this.taskExecutor.getTaskCreateAndRunTimer()); }
public StandardMetrics(final SpecCatalog specCatalog, Optional<Config> sysConfig) { this.timeWindowSizeInMinutes = sysConfig.isPresent()? ConfigUtils.getInt(sysConfig.get(), ConfigurationKeys.METRIC_TIMER_WINDOW_SIZE_IN_MINUTES, ConfigurationKeys.DEFAULT_METRIC_TIMER_WINDOW_SIZE_IN_MINUTES) : ConfigurationKeys.DEFAULT_METRIC_TIMER_WINDOW_SIZE_IN_MINUTES; this.metricsContext = specCatalog.getMetricContext(); this.timeForSpecCatalogGet = metricsContext.contextAwareTimer(TIME_FOR_SPEC_CATALOG_GET, timeWindowSizeInMinutes, TimeUnit.MINUTES); this.totalAddedSpecs = new AtomicLong(0); this.totalDeletedSpecs = new AtomicLong(0); this.totalUpdatedSpecs = new AtomicLong(0); this.numActiveSpecs = metricsContext.newContextAwareGauge(NUM_ACTIVE_SPECS_NAME, ()->{ long startTime = System.currentTimeMillis(); int size = specCatalog.getSpecs().size(); updateGetSpecTime(startTime); return size; }); this.totalAddCalls = metricsContext.newContextAwareGauge(TOTAL_ADD_CALLS, ()->this.totalAddedSpecs.get()); this.totalUpdateCalls = metricsContext.newContextAwareGauge(TOTAL_UPDATE_CALLS, ()->this.totalUpdatedSpecs.get()); this.totalDeleteCalls = metricsContext.newContextAwareGauge(TOTAL_DELETE_CALLS, ()->this.totalDeletedSpecs.get()); this.contextAwareMetrics.add(numActiveSpecs); this.contextAwareMetrics.add(totalAddCalls); this.contextAwareMetrics.add(totalUpdateCalls); this.contextAwareMetrics.add(totalDeleteCalls); this.contextAwareMetrics.add(timeForSpecCatalogGet); }
public StandardMetrics(final GobblinInstanceDriver parent) { this.uptimeMs = parent.getMetricContext().newContextAwareGauge(UPTIMEMS_NAME, new Gauge<Long>() { @Override public Long getValue() { return startTimeMs > 0 ? System.currentTimeMillis() - startTimeMs : 0; } }); this.upFlag = parent.getMetricContext().newContextAwareGauge(UPFLAG_NAME, new Gauge<Integer>() { @Override public Integer getValue() { switch (parent.state()) { case RUNNING: return 1; case FAILED: return -1; default: return 0; } } }); this.numUnclassifiedErrors = parent.getMetricContext().contextAwareCounter(NUM_UNCLASSIFIED_ERRORS_NAME); parent.addListener(this, new Executor() { @Override public void execute(Runnable command) { command.run(); } }); }
public StandardMetrics(final JobExecutionLauncher parent) { this.numJobsLaunched = parent.getMetricContext().contextAwareCounter(NUM_JOBS_LAUNCHED); this.numJobsCompleted = parent.getMetricContext().contextAwareCounter(NUM_JOBS_COMPLETED); this.numJobsCommitted = parent.getMetricContext().contextAwareCounter(NUM_JOBS_COMMITTED); this.numJobsFailed = parent.getMetricContext().contextAwareCounter(NUM_JOBS_FAILED); this.numJobsCancelled = parent.getMetricContext().contextAwareCounter(NUM_JOBS_CANCELLED); this.numJobsRunning = parent.getMetricContext().newContextAwareGauge(NUM_JOBS_RUNNING, new Gauge<Integer>() { @Override public Integer getValue() { return (int)(StandardMetrics.this.getNumJobsLaunched().getCount() - StandardMetrics.this.getNumJobsCompleted().getCount() - StandardMetrics.this.getNumJobsCancelled().getCount()); } }); } }