@Override public void updateTaskMetrics(Metrics metrics) { metrics.incrementCounter(MetricsConstant.HIVE_MR_TASKS); }
protected final MetricsScope updateOperationStateMetrics(MetricsScope stateScope, String operationPrefix, String completedOperationPrefix, OperationState state) { Metrics metrics = MetricsFactory.getInstance(); if (metrics != null) { if (stateScope != null) { metrics.endScope(stateScope); stateScope = null; } if (scopeStates.contains(state)) { stateScope = metrics.createScope(MetricsConstant.API_PREFIX + operationPrefix + state); } if (terminalStates.contains(state)) { metrics.incrementCounter(completedOperationPrefix + state); } } return stateScope; }
private void registerOpenSesssionMetrics(Metrics metrics) { MetricsVariable<Integer> openSessionCnt = new MetricsVariable<Integer>() { @Override public Integer getValue() { return getSessions().size(); } }; MetricsVariable<Integer> openSessionTime = new MetricsVariable<Integer>() { @Override public Integer getValue() { long sum = 0; long currentTime = System.currentTimeMillis(); for (HiveSession s : getSessions()) { sum += currentTime - s.getCreationTime(); } // in case of an overflow return -1 return (int) sum != sum ? -1 : (int) sum; } }; metrics.addGauge(MetricsConstant.HS2_OPEN_SESSIONS, openSessionCnt); metrics.addRatio(MetricsConstant.HS2_AVG_OPEN_SESSION_TIME, openSessionTime, openSessionCnt); }
metrics.incrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1); metrics.decrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1);
@Override public void afterCompile(QueryLifeTimeHookContext ctx, boolean hasError) { if (metrics != null && compilingQryScp != null) { metrics.endScope(compilingQryScp); } }
public static void decrementMetric(String name, long count) { Metrics metrics = MetricsFactory.getInstance(); if (metrics != null) { metrics.decrementCounter(name, count); } }
@Override public void beforeCompile(QueryLifeTimeHookContext ctx) { if (metrics != null) { compilingQryScp = metrics.createScope(MetricsConstant.HS2_COMPILING_QUERIES); } }
private static void registerMetrics(Metrics metrics, final QueryResultsCache cache) { MetricsVariable<Long> maxCacheSize = new MetricsVariable<Long>() { @Override public Long getValue() { return cache.maxCacheSize; } }; MetricsVariable<Long> curCacheSize = new MetricsVariable<Long>() { @Override public Long getValue() { return cache.cacheSize; } }; metrics.addGauge(MetricsConstant.QC_MAX_SIZE, maxCacheSize); metrics.addGauge(MetricsConstant.QC_CURRENT_SIZE, curCacheSize); }
@Test(expected = IllegalArgumentException.class) public void testMissingDenominatorRatio() throws Exception { MetricsFactory.getInstance().addRatio("rat", new NumericVariable(5), null); }
private void markQueryMetric(Metrics metric, String name) { if(metric != null) { metric.markMeter(name); } }
/** * Closes and removes static Metrics instance. */ public synchronized static void close() throws Exception { if (metrics != null) { metrics.close(); metrics = null; } } }
private void compileInternal(String command, boolean deferClose) throws CommandProcessorResponse { Metrics metrics = MetricsFactory.getInstance(); if (metrics != null) { metrics.incrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1); metrics.decrementCounter(MetricsConstant.WAITING_COMPILE_OPS, 1);
@Override public void afterExecution(QueryLifeTimeHookContext ctx, boolean hasError) { if (metrics != null && executingQryScp != null) { metrics.endScope(executingQryScp); } } }
private void decrementUserQueries(Metrics metrics) { String username = parentSession.getUserName(); if (username != null) { synchronized (userQueries) { AtomicInteger count = userQueries.get(username); if (count != null && count.decrementAndGet() <= 0) { metrics.decrementCounter(ACTIVE_SQL_USER); userQueries.remove(username); } } } }
@Override public void beforeExecution(QueryLifeTimeHookContext ctx) { if (metrics != null) { executingQryScp = metrics.createScope(MetricsConstant.HS2_EXECUTING_QUERIES); } }
String name = "WM_" + poolName + "_" + e.getKey(); codahaleNames.add(name); chMetrics.addGauge(name, var);
@Test(expected = IllegalArgumentException.class) public void testMissingNumeratorRatio() throws Exception { MetricsFactory.getInstance().addRatio("rat", null, new NumericVariable(5)); }
@Test public void testMeter() throws Exception { String json = ((CodahaleMetrics) MetricsFactory.getInstance()).dumpJson(); MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.METER, "meter", ""); MetricsFactory.getInstance().markMeter("meter"); json = ((CodahaleMetrics) MetricsFactory.getInstance()).dumpJson(); MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.METER, "meter", "1"); MetricsFactory.getInstance().markMeter("meter"); json = ((CodahaleMetrics) MetricsFactory.getInstance()).dumpJson(); MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.METER, "meter", "2"); }
@After public void tearDown() throws Exception { MetricsFactory.getInstance().close(); }
@Override public void updateTaskMetrics(Metrics metrics) { metrics.incrementCounter(MetricsConstant.HIVE_TEZ_TASKS); }