void registerGauge(String metricName, final long value) { try { MetricRegistry registry = Metrics.getInstance().getRegistry(); registry.register(metricName, (Gauge<Long>) () -> value); } catch (Exception e) { // Here we catch all exception, so the major upsert pipeline will not be affected if the // metrics system // has some issues. logger.error("Failed to send metrics: ", e); } }
public static synchronized void init(HoodieWriteConfig metricConfig) { if (initialized) { return; } try { metrics = new Metrics(metricConfig); } catch (ConfigurationException e) { throw new HoodieException(e); } initialized = true; }
public HoodieMetrics(HoodieWriteConfig config, String tableName) { this.config = config; this.tableName = tableName; if (config.isMetricsOn()) { Metrics.init(config); this.rollbackTimerName = getMetricsName("timer", HoodieTimeline.ROLLBACK_ACTION); this.cleanTimerName = getMetricsName("timer", HoodieTimeline.CLEAN_ACTION); this.commitTimerName = getMetricsName("timer", HoodieTimeline.COMMIT_ACTION); this.deltaCommitTimerName = getMetricsName("timer", HoodieTimeline.DELTA_COMMIT_ACTION); this.finalizeTimerName = getMetricsName("timer", "finalize"); this.compactionTimerName = getMetricsName("timer", HoodieTimeline.COMPACTION_ACTION); } }
public HoodieMetrics(HoodieWriteConfig config, String tableName) { this.config = config; this.tableName = tableName; if (config.isMetricsOn()) { Metrics.init(config); this.rollbackTimerName = getMetricsName("timer", HoodieTimeline.ROLLBACK_ACTION); this.cleanTimerName = getMetricsName("timer", HoodieTimeline.CLEAN_ACTION); this.commitTimerName = getMetricsName("timer", HoodieTimeline.COMMIT_ACTION); this.deltaCommitTimerName = getMetricsName("timer", HoodieTimeline.DELTA_COMMIT_ACTION); this.finalizeTimerName = getMetricsName("timer", "finalize"); this.compactionTimerName = getMetricsName("timer", HoodieTimeline.COMPACTION_ACTION); } }
private Timer createTimer(String name) { return config.isMetricsOn() ? Metrics.getInstance().getRegistry().timer(name) : null; }
public static synchronized void init(HoodieWriteConfig metricConfig) { if (initialized) { return; } try { metrics = new Metrics(metricConfig); } catch (ConfigurationException e) { throw new HoodieException(e); } initialized = true; }
void registerGauge(String metricName, final long value) { try { MetricRegistry registry = Metrics.getInstance().getRegistry(); registry.register(metricName, new Gauge<Long>() { @Override public Long getValue() { return value; } }); } catch (Exception e) { // Here we catch all exception, so the major upsert pipeline will not be affected if the // metrics system // has some issues. logger.error("Failed to send metrics: ", e); } }
private Timer createTimer(String name) { return config.isMetricsOn() ? Metrics.getInstance().getRegistry().timer(name) : null; }
@Test public void testRegisterGauge() { metrics.registerGauge("metric1", 123L); assertTrue(Metrics.getInstance().getRegistry().getGauges().get("metric1").getValue().toString().equals("123")); } }