Ejemplo n.º 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());
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 6
0
 protected static Metric asGauge(Metric m)
 {
     return new Metric(m.getConfig().withAdditionalTag(ATLAS_GAUGE_TAG), m.getTimestamp(), m.getValue());
 }
Ejemplo n.º 7
0
 protected static Metric asCounter(Metric m)
 {
     return new Metric(m.getConfig().withAdditionalTag(ATLAS_COUNTER_TAG), m.getTimestamp(), m.getValue());
 }