/** * Construct a new metric with a constant value. * @param name The name of the metric. * @param value The value of the metric. */ public SimpleMetric(MetricName name, String value) { this(name, MetricValue.fromStrValue(requireNonNull(value))); }
/** * Construct a new metric with a constant value. * @param name The name of the metric. * @param value The value of the metric. */ public SimpleMetric(MetricName name, String value) { this(name, MetricValue.fromStrValue(requireNonNull(value))); }
public ConstantStringExpression(String value) { value_ = Objects.requireNonNull(value); value_as_metric_ = new TimeSeriesMetricDeltaSet(MetricValue.fromStrValue(value_)); }
private static MetricValue pathAsMetricValue(Path path) { final List<String> pathElems = path.getPath(); if (pathElems.size() == 1) return strAsMetricValue(pathElems.get(0)); return MetricValue.fromStrValue(String.join(".", pathElems)); }
private static MetricValue strAsMetricValue(String str) { // Try to coerce elem to a boolean. if ("true".equals(str)) return MetricValue.TRUE; if ("false".equals(str)) return MetricValue.FALSE; // Try to coerce elem to an integral number. try { return MetricValue.fromIntValue(Long.parseLong(str)); } catch (NumberFormatException e) { // Ignore. } // Try to coerce elem to a floating point number. try { return MetricValue.fromDblValue(Double.parseDouble(str)); } catch (NumberFormatException e) { // Ignore. } // Give up and just yield a string. return MetricValue.fromStrValue(str); }
return Stream.of(SimpleMapEntry.create(MetricName.valueOf(attrPath), MetricValue.fromStrValue((String)attrObj)));
return Stream.of(SimpleMapEntry.create(MetricName.valueOf(attrPath), MetricValue.fromStrValue((String)attrObj)));
((Metric_constantContext)_localctx).s = MetricValue.fromStrValue((((Metric_constantContext)_localctx).s1_str!=null?((Metric_constantContext)_localctx).s1_str.getText():null));