parentMetricContext.or(Instrumented.getMetricContext(new org.apache.gobblin.configuration.State(), getClass())); this.metricContext = realParentCtx.childBuilder(TopologyCatalog.class.getSimpleName()).build(); this.metrics = new SpecCatalog.StandardMetrics(this, Optional.of(config)); this.addListener(this.metrics);
@Override public void onAddSpec(Spec addedSpec) { this.totalAddedSpecs.incrementAndGet(); submitTrackingEvent(addedSpec, SPEC_ADDED_OPERATION_TYPE); }
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); }
parentMetricContext.or(Instrumented.getMetricContext(new org.apache.gobblin.configuration.State(), getClass())); this.metricContext = realParentCtx.childBuilder(TopologyCatalog.class.getSimpleName()).build(); this.metrics = new SpecCatalog.StandardMetrics(this, Optional.of(config)); this.addListener(this.metrics);
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); }
private void submitTrackingEvent(Spec spec, String operType) { submitTrackingEvent(spec.getUri(), spec.getVersion(), operType); }
@Override public void onAddSpec(Spec addedSpec) { this.totalAddedSpecs.incrementAndGet(); submitTrackingEvent(addedSpec, SPEC_ADDED_OPERATION_TYPE); }
@Override public void onUpdateSpec(Spec updatedSpec) { this.totalUpdatedSpecs.incrementAndGet(); submitTrackingEvent(updatedSpec, SPEC_UPDATED_OPERATION_TYPE); } }
@Override public void onDeleteSpec(URI deletedSpecURI, String deletedSpecVersion, Properties headers) { this.totalDeletedSpecs.incrementAndGet(); submitTrackingEvent(deletedSpecURI, deletedSpecVersion, SPEC_DELETED_OPERATION_TYPE); }
private void submitTrackingEvent(Spec spec, String operType) { submitTrackingEvent(spec.getUri(), spec.getVersion(), operType); }
@Override public void onDeleteSpec(URI deletedSpecURI, String deletedSpecVersion, Properties headers) { this.totalDeletedSpecs.incrementAndGet(); submitTrackingEvent(deletedSpecURI, deletedSpecVersion, SPEC_DELETED_OPERATION_TYPE); }
@Override public void onUpdateSpec(Spec updatedSpec) { this.totalUpdatedSpecs.incrementAndGet(); submitTrackingEvent(updatedSpec, SPEC_UPDATED_OPERATION_TYPE); } }