protected void addValue(final long timestamp, final Metrics metrics, final String name, final String value) { metrics.add(name, timestamp, value); }
protected void addMetric(final long timestamp, final String name, final Object value) { values.add(name, timestamp, value); }
@Override public boolean parse(final String line, final Metrics metrics, final long timestamp) { if (line != null) { final String[] cols = line.split(":\\s*", 2); if (cols.length == 2) { final String name = cols[0].replace(' ', '_'); metrics.add(name, cols[0], timestamp, cols[1]); } else { logger.debug("Ignoring response line \"{}\"", metrics); } } return true; }
public boolean parse(final Metrics values, final long timestamp, final String line) { final Matcher matcher = pattern.matcher(line); if (matcher.matches()) { final String name = matcher.group(nameGroupIndex); final String value = matcher.group(valueGroupIndex); values.add(name, timestamp, value); return true; } else { return false; } } }
@Override public boolean parse(final String line, final Metrics metrics, final long timestamp) { if (line != null) { final String[] cols = line.split(":\\s*", 2); if (cols.length == 2) { final String name = cols[0].replace(' ', '_'); metrics.add(name, cols[0], timestamp, cols[1]); } else { logger.debug("Ignoring response line \"{}\"", metrics); } } return true; }
protected void addLatencyMetrics(final LatencyInfo info, final String prefix, final Metrics result) { final long timestamp = info.getEnd(); final Latency latency = info.getLatency(); result.add(prefix + ".totalRequests", timestamp, latency.getTotalRequests()); result.add(prefix + ".totalOperations", timestamp, latency.getTotalOps()); result.add(prefix + ".overflowRequests", timestamp, latency.getRequestsOverflow()); result.add(prefix + ".min", timestamp, latency.getMin()); result.add(prefix + ".max", timestamp, latency.getMax()); result.add(prefix + ".avg", timestamp, Math.round(latency.getAvg())); result.add(prefix + ".percentile95", timestamp, latency.get95thPercent()); result.add(prefix + ".percentile99", timestamp, latency.get99thPercent()); result.add(prefix + ".tps", timestamp, info.getThroughputPerSec()); }
public void addMetrics(Metrics result) { for (Entry<ResourceType, Map<ServiceStatus, Integer>> entry : statuses.entrySet()) { final ResourceType type = entry.getKey(); final int count = entry.getValue().values().stream().mapToInt(Integer::intValue).sum(); result.add(type.name().toLowerCase() + ".count", "Number of " + type.name() + " nodes", timestamp, count); for (Entry<ServiceStatus, Integer> entry2 : entry.getValue().entrySet()) { final ServiceStatus status = entry2.getKey(); result.add(type.name().toLowerCase() + ".status." + status.name().toLowerCase() + ".count", "Number of " + type.name() + " nodes in status " + status.name(), timestamp, entry2.getValue()); } } }
protected void fetchMetricsFromInfo(final long timestamp, final Metrics result) { final String info = jedis.info(); for (final LineIterator lines = IOUtils.lineIterator(new StringReader(info)); lines.hasNext(); ) { final String line = lines.next(); final String[] cols = line.split(":", 2); if (cols.length == 2) { result.add(cols[0], timestamp, cols[1]); } else { logger.debug("Failed to parse line \"{}\"", line); } } }
protected void fetchMetricsFromInfo(final long timestamp, final Metrics result) { final String info = jedis.info(); for (final LineIterator lines = IOUtils.lineIterator(new StringReader(info)); lines.hasNext(); ) { final String line = lines.next(); final String[] cols = line.split(":", 2); if (cols.length == 2) { result.add(cols[0], timestamp, cols[1]); } else { logger.debug("Failed to parse line \"{}\"", line); } } }
public void add(String name, MetricValue value) { add(new Metric(new SimpleMetricName(name, null), value)); } public void add(MetricName name, MetricValue value) {
public void add(MetricName name, long timestamp, Object value) { add(new Metric(name, new MetricValue(timestamp, value))); }
public void add(String name, MetricValue value) { add(new Metric(new SimpleMetricName(name, null), value)); } public void add(MetricName name, MetricValue value) {
private void addStatusMetrics(Metrics result) throws RemoteException { logger.debug("Loading the status map"); final ResourceTypeServiceStatusMetrics statusMetrics = new ResourceTypeServiceStatusMetrics(); for (ServiceChange item : service.getStatusMap().values()) { final ResourceType type = item.getTarget().getType(); statusMetrics.add(type, item.getStatus()); final String name = type.name().toLowerCase() + ".nodes." + item.getTarget().getFullName(); final long timestamp = System.currentTimeMillis(); result.add(name + ".status.ordinal", "0-STARTING,1-WAITING_FOR_DEPLOY,2-RUNNING,3-STOPPING,4-STOPPED,5-ERROR_RESTARTING,6-ERROR_NO_RESTART,7-UNREACHABLE,8-EXPECTED_RESTARTING", timestamp, item.getStatus().ordinal()); result.add(name + ".status.age", "The number of milliseconds since this change", timestamp, timestamp - item.getChangeTime()); } statusMetrics.addMetrics(result); }
protected Metrics transformValues(final Metrics metrics) { if (valueTransformers.isEmpty()) { return metrics; } else { logger.debug("Transforming values"); final Metrics result = new Metrics(); for (final Metric entry : metrics) { final MetricValue newValue = transformValue(entry.getName().getName(), entry.getValue()); result.add(new Metric(entry.getName(), newValue)); } return result; } }
protected Metrics readAlreadySelected(final MetaDataMetricsReader reader) { final List<SelectedMetric> matchingMetrics = getSelectedMetrics(reader); final Metrics result = new Metrics(); for (final SelectedMetric bean : matchingMetrics) { try { final MetricValue value = reader.readMetric(bean.getOriginalName()); result.add(bean.getName(), value); } catch (final MetricReadException e) { logger.warn("Failed to read " + bean.getOriginalName(), e); } } return result; }
protected void addTopologyMetrics(Metrics result) throws RemoteException { final long timestamp = System.currentTimeMillis(); final Topology topology = service.getTopology(); for (StorageNodeId snId : topology.getStorageNodeIds()) { final Set<RepNodeId> hostedRepNodes = topology.getHostedRepNodeIds(snId); for (RepNodeId rnId : topology.getRepNodeIds()) { final boolean hosted = hostedRepNodes.contains(rnId); final String name = snId.getType().name().toLowerCase() + ".nodes." + snId.getFullName() + ".hosting." + rnId.getFullName(); result.add(name, "Whether replication node " + rnId.getFullName() + " is hosted on " + snId.getFullName(), timestamp, hosted ? 1 : 0); } } }
protected Metrics readAlreadySelected(final MetaDataMetricsReader reader) { final List<SelectedMetric> matchingMetrics = getSelectedMetrics(reader); final Metrics result = new Metrics(); for (final SelectedMetric bean : matchingMetrics) { try { final MetricValue value = reader.readMetric(bean.getOriginalName()); result.add(bean.getName(), value); } catch (final MetricReadException e) { logger.warn("Failed to read " + bean.getOriginalName(), e); } } return result; }
public void add(String name, long timestamp, Object value) { add(new Metric(new SimpleMetricName(name, null), new MetricValue(timestamp, value))); }
protected Metrics readAllAndSelect(final BulkMetricsReader reader) { final Metrics result = new Metrics(); final Metrics metrics = reader.readAllMetrics(); for (final Metric entry : metrics) { final SelectedMetric metric = selectMetric(entry.getName()); if (metric != null) { result.add(metric.getName(), entry.getName().getDescription(), entry.getValue()); } } return result; }
protected Metrics readAllAndSelect(final BulkMetricsReader reader) { final Metrics result = new Metrics(); final Metrics metrics = reader.readAllMetrics(); for (final Metric entry : metrics) { final SelectedMetric metric = selectMetric(entry.getName()); if (metric != null) { result.add(metric.getName(), entry.getName().getDescription(), entry.getValue()); } } return result; }