use of com.ctrip.xpipe.metric.MetricData 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);
}
}
use of com.ctrip.xpipe.metric.MetricData in project x-pipe by ctripcorp.
the class MetricDelayCollector method getPoint.
private MetricData getPoint(HostPort hostPort, long value, DelaySampleResult result) {
MetricData data = new MetricData(TYPE, result.getClusterId(), result.getShardId());
data.setValue(value / 1000);
data.setTimestampMilli(System.currentTimeMillis());
data.setHostPort(hostPort);
return data;
}
use of com.ctrip.xpipe.metric.MetricData in project x-pipe by ctripcorp.
the class MetricDelayCollector method collect.
@Override
public void collect(DelaySampleResult result) {
try {
List<MetricData> data = new LinkedList<>();
for (Entry<HostPort, Long> entry : result.getSlaveHostPort2Delay().entrySet()) {
MetricData point = getPoint(entry.getKey(), entry.getValue(), result);
data.add(point);
}
HostPort masterHostPort = result.getMasterHostPort();
if (masterHostPort != null) {
MetricData point = getPoint(masterHostPort, result.getMasterDelayNanos(), result);
data.add(point);
}
proxy.writeBinMultiDataPoint(data);
} catch (Exception e) {
log.error("Error send metrics to metric", e);
}
}
use of com.ctrip.xpipe.metric.MetricData 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();
}
Aggregations