Search in sources :

Example 1 with MetricProxyException

use of com.ctrip.xpipe.metric.MetricProxyException in project x-pipe by ctripcorp.

the class HickwallMetric method log.

@Override
public void log(String desc, String metricSub, long delayNanos) {
    MetricData metricData = new MetricData(desc, clusterKey, metricSub);
    metricData.setTimestampMilli(System.currentTimeMillis());
    metricData.setValue(delayNanos);
    try {
        metricProxy.writeBinMultiDataPoint(Lists.newArrayList(metricData));
    } catch (MetricProxyException e) {
        logger.error("[log]", e);
    }
}
Also used : MetricData(com.ctrip.xpipe.metric.MetricData) MetricProxyException(com.ctrip.xpipe.metric.MetricProxyException)

Example 2 with MetricProxyException

use of com.ctrip.xpipe.metric.MetricProxyException in project x-pipe by ctripcorp.

the class HickwallMetricTest method testHickWall.

@Test
public void testHickWall() throws MetricProxyException, IOException {
    int port = 11111;
    logger.info("[testHickWall]{}", port);
    scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {

        @Override
        protected void doRun() throws Exception {
            List<MetricData> data = new LinkedList<>();
            HostPort hostPort = new HostPort("127.0.0.1", port);
            MetricData metricData = new MetricData("delay", "cluster", "shard");
            metricData.setValue(1000);
            metricData.setHostPort(hostPort);
            metricData.setTimestampMilli(System.currentTimeMillis());
            data.add(metricData);
            hickwallMetricProxy.writeBinMultiDataPoint(data);
        }
    }, 0, 2, TimeUnit.SECONDS);
    waitForAnyKeyToExit();
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) AbstractExceptionLogTask(com.ctrip.xpipe.concurrent.AbstractExceptionLogTask) List(java.util.List) LinkedList(java.util.LinkedList) IOException(java.io.IOException) MetricProxyException(com.ctrip.xpipe.metric.MetricProxyException) MetricData(com.ctrip.xpipe.metric.MetricData) Test(org.junit.Test) AbstractServiceTest(com.ctrip.xpipe.AbstractServiceTest)

Aggregations

MetricData (com.ctrip.xpipe.metric.MetricData)2 MetricProxyException (com.ctrip.xpipe.metric.MetricProxyException)2 AbstractServiceTest (com.ctrip.xpipe.AbstractServiceTest)1 AbstractExceptionLogTask (com.ctrip.xpipe.concurrent.AbstractExceptionLogTask)1 HostPort (com.ctrip.xpipe.endpoint.HostPort)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Test (org.junit.Test)1