Search in sources :

Example 1 with MetricFactory

use of com.yahoo.athenz.common.metrics.MetricFactory in project athenz by yahoo.

the class MetricNotificationServiceFactory method loadMetricObject.

Metric loadMetricObject() {
    String metricFactoryClass = System.getProperty(NOTIFICATION_PROP_METRIC_FACTORY_CLASS, METRIC_DEFAULT_FACTORY_CLASS);
    MetricFactory metricFactory;
    try {
        metricFactory = (MetricFactory) Class.forName(metricFactoryClass).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        LOG.error("Invalid MetricFactory class: {} error: {}", metricFactoryClass, e.getMessage());
        throw new IllegalArgumentException("Invalid metric class");
    }
    LOG.info("Loaded MetricFactory for receiving notification metrics: {}", metricFactoryClass);
    // create our metric
    return metricFactory.create();
}
Also used : MetricFactory(com.yahoo.athenz.common.metrics.MetricFactory)

Example 2 with MetricFactory

use of com.yahoo.athenz.common.metrics.MetricFactory in project athenz by yahoo.

the class JettyConnectionLoggerFactory method getMetric.

private static Metric getMetric() {
    final String metricFactoryClass = System.getProperty(JETTY_PROP_METRIC_FACTORY_CLASS, METRIC_DEFAULT_FACTORY_CLASS);
    MetricFactory metricFactory;
    try {
        metricFactory = (MetricFactory) Class.forName(metricFactoryClass).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        LOG.error("Invalid MetricFactory class: {} error: {}", metricFactoryClass, e.getMessage());
        throw new IllegalArgumentException("Invalid metric class");
    }
    return metricFactory.create();
}
Also used : MetricFactory(com.yahoo.athenz.common.metrics.MetricFactory)

Example 3 with MetricFactory

use of com.yahoo.athenz.common.metrics.MetricFactory in project athenz by yahoo.

the class MetricsTest method testFactoryNoOpMetric.

@Test
public void testFactoryNoOpMetric() throws Exception {
    MetricFactory factory = new NoOpMetricFactory();
    Metric metric = factory.create();
    assertEquals(metric.getClass().getName(), Class.forName("com.yahoo.athenz.common.metrics.impl.NoOpMetric").getName());
    metric.increment("metric1");
    metric.increment("metric1", "athenz");
    metric.increment("metric1", "athenz", 3);
    metric.increment("metric1", "athenz", "sports");
    metric.increment("metric1", "athenz", "sports", 3);
    metric.increment("apiRquestsMetric", "athenz", "sports", "POST", 200, "caller");
    String[] attributes = new String[] { "tag1", "value1", "tag2", "value2", "tag3", "value3" };
    metric.increment("metric1", attributes);
    assertNull(metric.startTiming("metric1", "athenz"));
    assertNull(metric.startTiming("metric1", "athenz", "sports"));
    assertNull(metric.startTiming("apiRquestsMetric", "athenz", "sports", "POST", "caller"));
    metric.stopTiming("metric1");
    metric.stopTiming("metric1", "athenz", "sports");
    metric.stopTiming("apiRquestsMetric", "athenz", "sports", "POST", 200, "caller");
    metric.flush();
    metric.quit();
}
Also used : MetricFactory(com.yahoo.athenz.common.metrics.MetricFactory) Metric(com.yahoo.athenz.common.metrics.Metric) Test(org.testng.annotations.Test)

Example 4 with MetricFactory

use of com.yahoo.athenz.common.metrics.MetricFactory in project athenz by yahoo.

the class ZTSImpl method loadMetricObject.

void loadMetricObject() {
    final String metricFactoryClass = System.getProperty(ZTSConsts.ZTS_PROP_METRIC_FACTORY_CLASS, METRIC_DEFAULT_FACTORY_CLASS);
    MetricFactory metricFactory;
    try {
        metricFactory = (MetricFactory) Class.forName(metricFactoryClass).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        LOGGER.error("Invalid MetricFactory class: {} error: {}", metricFactoryClass, e.getMessage());
        throw new IllegalArgumentException("Invalid metric class");
    }
    // create our metric and increment our startup count
    metric = metricFactory.create();
    metric.increment("zts_startup");
}
Also used : MetricFactory(com.yahoo.athenz.common.metrics.MetricFactory)

Example 5 with MetricFactory

use of com.yahoo.athenz.common.metrics.MetricFactory in project athenz by yahoo.

the class ZMSImpl method loadMetricObject.

void loadMetricObject() {
    String metricFactoryClass = System.getProperty(ZMSConsts.ZMS_PROP_METRIC_FACTORY_CLASS, METRIC_DEFAULT_FACTORY_CLASS);
    MetricFactory metricFactory;
    try {
        metricFactory = (MetricFactory) Class.forName(metricFactoryClass).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        LOG.error("Invalid MetricFactory class: {} error: {}", metricFactoryClass, e.getMessage());
        throw new IllegalArgumentException("Invalid metric class");
    }
    // create our metric and increment our startup count
    ZMSImpl.metric = metricFactory.create();
    metric.increment("zms_sa_startup");
}
Also used : MetricFactory(com.yahoo.athenz.common.metrics.MetricFactory)

Aggregations

MetricFactory (com.yahoo.athenz.common.metrics.MetricFactory)5 Metric (com.yahoo.athenz.common.metrics.Metric)1 Test (org.testng.annotations.Test)1