public static TimeSeries fromMetricName(MetricName metricName) throws IOException { String name = metricName.getName(); // check if it is a delta counter, then remove the delta prefix before parsing // (delta prefix had to be removed, because the name contains json and jackson parser fails // to parse the delta prefix) boolean deltaCounter = DeltaCounter.isDelta(name); if (deltaCounter) { name = DeltaCounter.getNameWithoutDeltaPrefix(name); } Decoder decoder = DecoderFactory.get().jsonDecoder(TimeSeries.SCHEMA$, name); TimeSeries toReturn = datumReader.read(null, decoder); // add the delta prefix back if (deltaCounter) { String newName = DeltaCounter.getDeltaCounterName(toReturn.getMetric()); toReturn.setMetric(newName); } return toReturn; }
public static TimeSeries fromMetricName(MetricName metricName) throws IOException { String name = metricName.getName(); // check if it is a delta counter, then remove the delta prefix before parsing // (delta prefix had to be removed, because the name contains json and jackson parser fails // to parse the delta prefix) boolean deltaCounter = DeltaCounter.isDelta(name); if (deltaCounter) { name = DeltaCounter.getNameWithoutDeltaPrefix(name); } Decoder decoder = DecoderFactory.get().jsonDecoder(TimeSeries.SCHEMA$, name); TimeSeries toReturn = datumReader.read(null, decoder); // add the delta prefix back if (deltaCounter) { String newName = DeltaCounter.getDeltaCounterName(toReturn.getMetric()); toReturn.setMetric(newName); } return toReturn; }
/** * This method transforms the MetricName into a new MetricName that represents a DeltaCounter. * The transformation includes prepending a "\u2206" character to the name. * * @param metricName The MetricName which needs to be transformed * @return The new MetricName representing a DeltaCounter */ public static MetricName getDeltaCounterMetricName(MetricName metricName) { if (isDelta(metricName.getName())) { return metricName; } else { String name = getDeltaCounterName(metricName.getName()); return new MetricName(metricName.getGroup(), metricName.getType(), name, metricName.getScope()); } }
/** * This method transforms the MetricName into a new MetricName that represents a DeltaCounter. * The transformation includes prepending a "\u2206" character to the name. * * @param metricName The MetricName which needs to be transformed * @return The new MetricName representing a DeltaCounter */ public static MetricName getDeltaCounterMetricName(MetricName metricName) { if (isDelta(metricName.getName())) { return metricName; } else { String name = getDeltaCounterName(metricName.getName()); return new MetricName(metricName.getGroup(), metricName.getType(), name, metricName.getScope()); } }