/// <summary> /// Return a new metric where the name and all tags are using the valid character set. /// </summary> /// <param name="metric"></param> /// <returns></returns> public static Metric toValidValue(Metric metric) { MonitorConfig cfg = metric.getConfig(); MonitorConfig.Builder cfgBuilder = MonitorConfig.builder(toValidCharset(cfg.getName())); foreach (ITag orig in cfg.getTags()) { cfgBuilder.withTag(toValidCharset(orig.Key), toValidCharset(orig.Value)); } cfgBuilder.withPublishingPolicy(cfg.getPublishingPolicy()); return new Metric(cfgBuilder.build(), metric.getTimestamp(), metric.getValue()); }
private AtlasMetric BuildAtlasMetric(Metric metric) { var local = ValidCharacters.toValidValue(metric); if (isCounter(local)) local = asCounter(local); else if (isGauge(local)) local = asGauge(local); BasicTagList tags = local.getConfig().getTags() as BasicTagList; var asd = SmallTagMap.builder() .add(new NameTag(local.getConfig().getName())); var atlasTags = new BasicTagList(asd.result()); var tagsWithName = tags.copy(atlasTags); return new AtlasMetric(local.getValue(), local.getTimestamp(), tagsWithName); }
protected bool isRate(Metric m) { ITagList tags = m.getConfig().getTags(); string value = tags.getValue(DataSourceType.KEY); return DataSourceType.RATE.name.Equals(value) || DataSourceType.NORMALIZED.name.Equals(value); }
protected bool isGauge(Metric m) { ITagList tags = m.getConfig().getTags(); string value = tags.getValue(DataSourceType.KEY); return value != null && value.Equals(DataSourceType.GAUGE.name); }
protected static bool isCounter(Metric m) { ITagList tags = m.getConfig().getTags(); string value = tags.getValue(DataSourceType.KEY); return value != null && value.Equals(DataSourceType.COUNTER.name); }
protected static Metric asGauge(Metric m) { return new Metric(m.getConfig().withAdditionalTag(ATLAS_GAUGE_TAG), m.getTimestamp(), m.getValue()); }
protected static Metric asCounter(Metric m) { return new Metric(m.getConfig().withAdditionalTag(ATLAS_COUNTER_TAG), m.getTimestamp(), m.getValue()); }