本文整理汇总了Java中com.singularity.ee.agent.systemagent.api.MetricWriter类的典型用法代码示例。如果您正苦于以下问题:Java MetricWriter类的具体用法?Java MetricWriter怎么用?Java MetricWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricWriter类属于com.singularity.ee.agent.systemagent.api包,在下文中一共展示了MetricWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
public void run() {
displayName = convertToString(server.get(DISPLAY_NAME), "");
long startTime = System.currentTimeMillis();
MetricPrinter metricPrinter = new MetricPrinter(metricPrefix, displayName, metricWriter);
try {
logger.debug(String.format("Kafka monitor thread for server {} started.", displayName));
BigDecimal status = extractAndReportMetrics(metricPrinter);
metricPrinter.printMetric(metricPrinter.formMetricPath(METRICS_COLLECTION_SUCCESSFUL), status
, MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION, MetricWriter.METRIC_TIME_ROLLUP_TYPE_CURRENT, MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL);
} catch (Exception e) {
logger.error(String.format("Error in Kafka Monitor thread for server {}", displayName), e);
metricPrinter.printMetric(metricPrinter.formMetricPath(METRICS_COLLECTION_SUCCESSFUL), ERROR_VALUE
, MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION, MetricWriter.METRIC_TIME_ROLLUP_TYPE_CURRENT, MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL);
} finally {
long endTime = System.currentTimeMillis() - startTime;
logger.debug(String.format("Kafka monitor thread for server {%s} ended. Time taken = {%s} and Total metrics reported = {%d}", displayName, endTime, metricPrinter.getTotalMetricsReported()));
}
}
示例2: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
/**
* @param metrics
*/
private void printMetric(Map<String, Number> metrics) {
for (Map.Entry<String, Number> metric : metrics.entrySet()) {
MetricWriter metricWriter = super.getMetricWriter(metric.getKey(), MetricWriter.METRIC_AGGREGATION_TYPE_AVERAGE, MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE, MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_COLLECTIVE
);
Object metricValue = metric.getValue();
if (metricValue instanceof BigDecimal) {
metricWriter.printMetric(String.valueOf(((BigDecimal) metricValue).longValue()));
} else if (metricValue instanceof Double) {
metricWriter.printMetric(String.valueOf(Math.round((Double) metricValue)));
} else if (metricValue instanceof Float) {
metricWriter.printMetric(String.valueOf(Math.round((Float) metricValue)));
} else {
metricWriter.printMetric(String.valueOf(metricValue));
}
}
}
示例3: run
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
public void run () {
serverName = CassandraUtil.convertToString(server.get(DISPLAY_NAME), "");
MetricPrinter metricPrinter = new MetricPrinter(metricPrefix, serverName, metricWriter);
try {
logger.debug("Cassandra monitoring task initiated for server {}", serverName);
BigDecimal status = populateAndPrintStats(metricPrinter);
metricPrinter.printMetric(metricPrinter.formMetricPath(METRICS_COLLECTION_SUCCESSFUL), status,
MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION, MetricWriter.METRIC_TIME_ROLLUP_TYPE_CURRENT,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL);
} catch (Exception e) {
logger.error("Error in Cassandra Monitoring Task for Server {}", serverName, e);
metricPrinter.printMetric(metricPrinter.formMetricPath(METRICS_COLLECTION_SUCCESSFUL), BigDecimal.ZERO,
MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION, MetricWriter.METRIC_TIME_ROLLUP_TYPE_CURRENT,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL);
} finally {
logger.debug("Cassandra Monitoring Task Complete. Total number of metrics reported = {}", metricPrinter
.getTotalMetricsReported());
}
}
示例4: print
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
/**
*
*/
public void print() {
LOG.info("Printing metrics.");
// Publish status to the controller instance.
for (NagiosScript script : scripts) {
if (!script.isRunAll()) {
String exitCode = String.valueOf(script.getExitCode());
LOG.info("NAME: " + script.getName() + " VALUE: " + exitCode);
printMetric(
script.getName(),
exitCode,
MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION, MetricWriter.METRIC_TIME_ROLLUP_TYPE_CURRENT,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_COLLECTIVE);
}
}
}
示例5: run
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
public void run() {
serverName = ActiveMQUtil.convertToString(server.get(DISPLAY_NAME), "");
MetricPrinter metricPrinter = new MetricPrinter(metricPrefix, serverName, metricWriter);
try {
logger.debug("ActiveMQ monitoring task initiated for server {}", serverName);
BigDecimal status = populateAndPrintStats(metricPrinter);
metricPrinter.printMetric(metricPrinter.formMetricPath(METRICS_COLLECTION_SUCCESSFUL), status,
MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION, MetricWriter.METRIC_TIME_ROLLUP_TYPE_CURRENT,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL);
} catch (Exception e) {
logger.error("Error in ActiveMQ Monitoring Task for Server {}", serverName, e);
metricPrinter.printMetric(metricPrinter.formMetricPath(METRICS_COLLECTION_SUCCESSFUL), BigDecimal.ZERO,
MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION, MetricWriter.METRIC_TIME_ROLLUP_TYPE_CURRENT,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL);
} finally {
logger.debug("ActiveMQ Monitoring Task Complete. Total number of metrics reported = {}", metricPrinter
.getTotalMetricsReported());
}
}
示例6: printMetrics
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
/**
* Writes the cache metrics to the controller
* @param metricsMap HashMap containing all the cache metrics
*/
private void printMetrics(HashMap metricsMap) throws Exception{
HashMap<String, HashMap<String, Number>> metrics = (HashMap<String,HashMap<String,Number>>) metricsMap;
Iterator outerIterator = metrics.keySet().iterator();
while (outerIterator.hasNext()) {
String id = outerIterator.next().toString();
HashMap<String, Number> cacheStatistics = metrics.get(id);
Iterator innerIterator = cacheStatistics.keySet().iterator();
while (innerIterator.hasNext()) {
String metricName = innerIterator.next().toString();
Number metric = cacheStatistics.get(metricName);
printMetric(id + "|" + metricName, metric,
MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION,
MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL);
}
}
}
示例7: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
/**
* Returns the metric to the AppDynamics Controller.
*
* @param metricPrefix Metric prefix
* @param metricName Name of the Metric
* @param metricValue Value of the Metric
*/
private void printMetric(String metricPrefix, String metricName, Object metricValue) {
String aggregation = MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION;
String timeRollup = MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE;
String cluster = MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_COLLECTIVE;
String serverName = (String) server.get("name");
String metricPath = metricPrefix + METRIC_SEPARATOR + serverName + METRIC_SEPARATOR + metricName;
MetricWriteHelper metricWriter = configuration.getMetricWriter();
metricWriter.printMetric(metricPath, metricValue.toString(), aggregation, timeRollup, cluster);
if (logger.isDebugEnabled()) {
logger.debug("Metric [" + aggregation + "/" + timeRollup + "/" + cluster
+ "] metric = " + metricPath + " = " + metricValue);
}
}
示例8: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
/**
* Returns the metric to the AppDynamics Controller.
*
* @param metricName Name of the Metric
* @param metricValue Value of the Metric
*/
protected void printMetric(String metricName, Object metricValue) {
if (metricValue != null) {
String value = MetricUtils.toWholeNumberString(metricValue);
if (!Strings.isNullOrEmpty(value)) {
logger.debug(String.format("Printing metric %s with value %s", metricName, metricValue));
metricWriter.printMetric(metricPrefix + "|" + metricName, value, MetricWriter.METRIC_AGGREGATION_TYPE_OBSERVATION,
MetricWriter.METRIC_TIME_ROLLUP_TYPE_CURRENT, MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL);
} else {
logger.info(String.format("Ignoring metric %s as it has no value", metricName));
}
} else {
logger.info(String.format("Ignoring metric %s as it has null value", metricName));
}
}
示例9: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
/**
* Returns the metric to the AppDynamics Controller.
*
* @param metricName Name of the Metric
* @param metricValue Value of the Metric
*/
public void printMetric(String metricName, Number metricValue) {
if (metricValue != null) {
if(metricName.contains(",")) {
metricName = metricName.replaceAll(",", ":");
}
try {
MetricWriter metricWriter = getMetricWriter(metricName,
MetricWriter.METRIC_AGGREGATION_TYPE_AVERAGE,
MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL
);
metricWriter.printMetric(MetricUtils.toWholeNumberString(metricValue));
} catch (Exception e) {
logger.error("Exception while reporting metric " + metricName + " : " + metricValue, e);
}
} else {
logger.warn("Metric " + metricName + " is null");
}
}
示例10: printMetrics
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
private void printMetrics(Map<String, BigDecimal> solrMetrics) {
MetricWriteHelper metricWriter = configuration.getMetricWriter();
String metricPrefix = configuration.getMetricPrefix();
String aggregation = MetricWriter.METRIC_AGGREGATION_TYPE_AVERAGE;
String cluster = MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_INDIVIDUAL;
String timeRollup = MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE;
for (Map.Entry<String, BigDecimal> entry : solrMetrics.entrySet()) {
String metricPath = metricPrefix + "|" + server.get("name").toString() + entry.getKey();
String metricValue = String.valueOf(entry.getValue());
metricWriter.printMetric(metricPath, metricValue, aggregation, timeRollup, cluster);
}
}
示例11: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
private void printMetric(String metricPath, Number metricValue, String aggregation, String timeRollup, String cluster) {
MetricWriter metricWriter = super.getMetricWriter(metricPath, aggregation, timeRollup, cluster);
if (metricValue != null) {
if (logger.isDebugEnabled()) {
logger.debug("Metric [" + metricPath + " = " + metricValue + "]");
}
if (metricValue instanceof Double) {
metricWriter.printMetric(String.valueOf(Math.round((Double) metricValue)));
} else if (metricValue instanceof Float) {
metricWriter.printMetric(String.valueOf(Math.round((Float) metricValue)));
} else {
metricWriter.printMetric(String.valueOf(metricValue));
}
}
}
示例12: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
private void printMetric(String metricPath, String metricName, Object metricValue) {
if (metricValue != null) {
MetricWriter metricWriter = super.getMetricWriter(getMetricPrefix() + metricPath + metricName,
MetricWriter.METRIC_AGGREGATION_TYPE_AVERAGE, MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE,
MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_COLLECTIVE);
metricWriter.printMetric(String.valueOf(metricValue));
}
}
示例13: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
private void printMetric(String metricPrefix, String metricPath, Object metricValue) {
MetricWriter metricWriter = super.getMetricWriter(metricPrefix + metricPath, MetricWriter.METRIC_AGGREGATION_TYPE_AVERAGE, MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE, MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_COLLECTIVE
);
if (metricValue instanceof Double) {
metricWriter.printMetric(String.valueOf(Math.round((Double) metricValue)));
} else if (metricValue instanceof Float) {
metricWriter.printMetric(String.valueOf(Math.round((Float) metricValue)));
} else {
metricWriter.printMetric(String.valueOf(metricValue));
}
}
示例14: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
public void printMetric(String metricName, String metricValue) {
if (metricValue != null) {
//logger.debug(metricName + " : " + metricValue);
configuration.getMetricWriter().printMetric(metricName, metricValue, MetricWriter.METRIC_AGGREGATION_TYPE_AVERAGE,MetricWriter.METRIC_TIME_ROLLUP_TYPE_AVERAGE, MetricWriter.METRIC_CLUSTER_ROLLUP_TYPE_COLLECTIVE);
} else {
logger.warn("The metric at " + metricName + " is null");
}
}
示例15: printMetric
import com.singularity.ee.agent.systemagent.api.MetricWriter; //导入依赖的package包/类
private void printMetric(String metricPath, String metricValue, String aggregation, String timeRollup, String cluster) {
MetricWriter metricWriter = super.getMetricWriter(metricPath, aggregation, timeRollup, cluster);
if (metricValue != null) {
if (logger.isDebugEnabled()) {
logger.debug("Metric [" + metricPath + " = " + metricValue + "]");
}
metricWriter.printMetric(metricValue);
}
}