/** * Get the counter metric with the supplied name, within the scope of this monitor. * * @param name the name of the counter * @return the counter */ public Counter counter(String name) { return metrics.getCounter(name); }
/** * Get the timer metric with the supplied name, within the scope of this monitor. * * @param name the name of the timer * @return the timer */ public Timer timer(String name) { return metrics.getTimer(name); }
/** * Get a new metrics provider for a specific class, without a prefix. * * @param clazz * @return */ public static Metrics getMetrics(Class<?> clazz) { return new Metrics(getInstance(), clazz); }
/** * Get the meter metric with the supplied name, within the scope of this monitor. * * @param name the name of the meter * @return the meter */ public Meter meter(String name) { return metrics.getMeter(name); }
@Test public void testGetHistogram() { metrics.getHistogram("histogram"); verify(factory).getHistogram(anyString(), eq("histogram")); }
@Test public void testInstance() { assertNotNull(MetricsFactory.getInstance()); Metrics m1 = MetricsFactory.getMetrics(MetricsFactoryTest.class); Metrics m2 = MetricsFactory.getMetrics("Testing", MetricsFactoryTest.class); assertTrue(m1.getBase().contains(MetricsFactoryTest.class.getCanonicalName())); assertTrue(m2.getBase().contains(MetricsFactoryTest.class.getCanonicalName())); assertTrue(m2.getBase().startsWith("Testing")); }
/** * Get the meter metric with the supplied name, within the scope of this monitor. * * @param name the name of the meter * @return the meter */ public Meter meter(String name) { return metrics.getMeter(name); }
/** * Get the histogram metric with the supplied name, within the scope of this monitor. * * @param name the name of the histogram * @return the histogram */ public Counter histogram(String name) { return metrics.getCounter(name); }
/** * Get the timer metric with the supplied name, within the scope of this monitor. * * @param name the name of the timer * @return the timer */ public Timer timer(String name) { return metrics.getTimer(name); }
/** * Get a new metrics provider for a specific class. * * @param prefix * @param clazz * @return */ public static Metrics getMetrics(String prefix, Class<?> clazz) { return new Metrics(getInstance(), prefix, clazz); }
@Test public void testGetMeter() { metrics.getMeter("meter"); verify(factory).getMeter(anyString(), eq("meter")); } }
/** * Get the counter metric with the supplied name, within the scope of this monitor. * * @param name the name of the counter * @return the counter */ public Counter counter(String name) { return metrics.getCounter(name); }
/** * Start a timer at the start of the function, and log that the function is about to begin. Logs * to TRACE level rather than DEBUG, as some functions are called so often we don't want to fill * up the logs! * * @param functionName The name of the function */ public void startFunctionTrace(String functionName) { logger.trace("Starting function {}", functionName); timers.put(functionName, metrics.getTimer(functionName).time()); }
/** * Get a new metrics provider for a specific class, without a prefix. * * @param clazz * @return */ public static Metrics getMetrics(Class<?> clazz) { return new Metrics(getInstance(), clazz); }
/** * Get the histogram metric with the supplied name, within the scope of this monitor. * * @param name the name of the histogram * @return the histogram */ public Counter histogram(String name) { return metrics.getCounter(name); }
/** * Start a timer at the start of the function, and log that the function is about to begin * * @param functionName The name of the function */ public void startFunction(String functionName) { logger.debug("Starting function {}", functionName); timers.put(functionName, metrics.getTimer(functionName).time()); }
/** * Get a new metrics provider for a specific class. * * @param prefix * @param clazz * @return */ public static Metrics getMetrics(String prefix, Class<?> clazz) { return new Metrics(getInstance(), prefix, clazz); }
/** * Persist entity counts into the Metrics object, as we only want to do this once per process() * function and not every time we add an entity. */ public void persistCounts() { for (Entry<String, Long> entry : entityAddedCounts.entrySet()) { metrics.getCounter(entry.getKey() + "-added").inc(entry.getValue()); } entityAddedCounts.clear(); for (Entry<String, Long> entry : entityRemovedCounts.entrySet()) { metrics.getCounter(entry.getKey() + "-removed").inc(entry.getValue()); } entityRemovedCounts.clear(); }