예제 #1
0
 /// <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());
 }
예제 #2
0
        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);
        }
예제 #3
0
 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);
 }
예제 #4
0
 protected bool isGauge(Metric m)
 {
     ITagList tags = m.getConfig().getTags();
     string value = tags.getValue(DataSourceType.KEY);
     return value != null && value.Equals(DataSourceType.GAUGE.name);
 }
예제 #5
0
 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);
 }
예제 #6
0
 protected static Metric asGauge(Metric m)
 {
     return new Metric(m.getConfig().withAdditionalTag(ATLAS_GAUGE_TAG), m.getTimestamp(), m.getValue());
 }
예제 #7
0
 protected static Metric asCounter(Metric m)
 {
     return new Metric(m.getConfig().withAdditionalTag(ATLAS_COUNTER_TAG), m.getTimestamp(), m.getValue());
 }