congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
MetricValue.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
co.cask.cdap.api.metrics.MetricValue
constructor

Best Java code snippets using co.cask.cdap.api.metrics.MetricValue.<init> (Showing top 7 results out of 315)

origin: cdapio/cdap

public MetricValues(Map<String, String> tags, String name, long timestamp, long value, MetricType type) {
 this.tags = tags;
 this.timestamp = timestamp;
 this.metrics = ImmutableList.of(new MetricValue(name, type, value));
}
origin: caskdata/cdap

@Override
public MetricValue emit() {
 // todo CDAP-2195 - potential race condition , reseting value and type has to be done together
 long value = this.value.getAndSet(0);
 MetricType type = gaugeUsed.getAndSet(false) ? MetricType.GAUGE : MetricType.COUNTER;
 return new MetricValue(name, type, value);
}
origin: co.cask.cdap/cdap-watchdog

@Override
public MetricValue emit() {
 // todo CDAP-2195 - potential race condition , reseting value and type has to be done together
 long value = this.value.getAndSet(0);
 MetricType type = gaugeUsed.getAndSet(false) ? MetricType.GAUGE : MetricType.COUNTER;
 return new MetricValue(name, type, value);
}
origin: caskdata/cdap

/**
 * Persist metrics into metric store
 *
 * @param metricValues a non-empty deque of {@link MetricValues}
 */
private void persistMetrics(Deque<MetricValues> metricValues,
              Map<TopicIdMetaKey, TopicProcessMeta> topicProcessMetaMap) {
 long now = System.currentTimeMillis();
 long lastMetricTime = metricValues.peekLast().getTimestamp();
 List<MetricValue> topicLevelDelays = new ArrayList<>();
 //add topic level delay metrics
 for (Map.Entry<TopicIdMetaKey, TopicProcessMeta> entry : topicProcessMetaMap.entrySet()) {
  TopicProcessMeta topicProcessMeta = entry.getValue();
  long delay = now - TimeUnit.SECONDS.toMillis(topicProcessMeta.getOldestMetricsTimestamp());
  topicLevelDelays.add(new MetricValue(topicProcessMeta.getOldestMetricsTimestampMetricName(),
                     MetricType.GAUGE, delay));
  delay = now - TimeUnit.SECONDS.toMillis(topicProcessMeta.getLatestMetricsTimestamp());
  topicLevelDelays.add(new MetricValue(topicProcessMeta.getLatestMetricsTimestampMetricName(),
                     MetricType.GAUGE, delay));
 }
 List<MetricValue> processorMetrics = new ArrayList<>(topicLevelDelays);
 processorMetrics.add(new MetricValue(processMetricName, MetricType.COUNTER, metricValues.size()));
 metricValues.add(new MetricValues(metricsContextMap, TimeUnit.MILLISECONDS.toSeconds(now), processorMetrics));
 metricStore.add(metricValues);
 metricsProcessedCount += metricValues.size();
 PROGRESS_LOG.debug("{} metrics persisted. Last metric's timestamp: {}",
           metricsProcessedCount, lastMetricTime);
}
origin: co.cask.cdap/cdap-watchdog

/**
 * Persist metrics into metric store
 *
 * @param metricValues a non-empty deque of {@link MetricValues}
 */
private void persistMetrics(Deque<MetricValues> metricValues,
              Map<TopicIdMetaKey, TopicProcessMeta> topicProcessMetaMap) {
 long now = System.currentTimeMillis();
 long lastMetricTime = metricValues.peekLast().getTimestamp();
 List<MetricValue> topicLevelDelays = new ArrayList<>();
 //add topic level delay metrics
 for (Map.Entry<TopicIdMetaKey, TopicProcessMeta> entry : topicProcessMetaMap.entrySet()) {
  TopicProcessMeta topicProcessMeta = entry.getValue();
  long delay = now - TimeUnit.SECONDS.toMillis(topicProcessMeta.getOldestMetricsTimestamp());
  topicLevelDelays.add(new MetricValue(topicProcessMeta.getOldestMetricsTimestampMetricName(),
                     MetricType.GAUGE, delay));
  delay = now - TimeUnit.SECONDS.toMillis(topicProcessMeta.getLatestMetricsTimestamp());
  topicLevelDelays.add(new MetricValue(topicProcessMeta.getLatestMetricsTimestampMetricName(),
                     MetricType.GAUGE, delay));
 }
 List<MetricValue> processorMetrics = new ArrayList<>(topicLevelDelays);
 processorMetrics.add(new MetricValue(processMetricName, MetricType.COUNTER, metricValues.size()));
 metricValues.add(new MetricValues(metricsContextMap, TimeUnit.MILLISECONDS.toSeconds(now), processorMetrics));
 metricStore.add(metricValues);
 metricsProcessedCount += metricValues.size();
 PROGRESS_LOG.debug("{} metrics persisted. Last metric's timestamp: {}",
           metricsProcessedCount, lastMetricTime);
}
origin: caskdata/cdap

 @Override
 protected MetricValues computeNext() {
  while (iterator.hasNext()) {
   Map.Entry<Map<String, String>, LoadingCache<String, AggregatedMetricsEmitter>> entry = iterator.next();
   Map<String, AggregatedMetricsEmitter> metricEmitters = entry.getValue().asMap();
   // +1 because we add extra metric about how many metric values did we emit in this context (see below)
   List<MetricValue> metricValues = Lists.newArrayListWithCapacity(metricEmitters.size() + 1);
   for (Map.Entry<String, AggregatedMetricsEmitter> emitterEntry : metricEmitters.entrySet()) {
    MetricValue metricValue = emitterEntry.getValue().emit();
    // skip increment by 0
    if (metricValue.getType() == MetricType.COUNTER && metricValue.getValue() == 0) {
     continue;
    }
    metricValues.add(metricValue);
   }
   if (metricValues.isEmpty()) {
    // skip if there are no metric values to send
    continue;
   }
   // number of emitted metrics
   metricValues.add(new MetricValue("metrics.emitted.count", MetricType.COUNTER, metricValues.size() + 1));
   LOG.trace("Emit metric {}", metricValues);
   return new MetricValues(entry.getKey(), timestamp, metricValues);
  }
  return endOfData();
 }
};
origin: co.cask.cdap/cdap-watchdog

 @Override
 protected MetricValues computeNext() {
  while (iterator.hasNext()) {
   Map.Entry<Map<String, String>, LoadingCache<String, AggregatedMetricsEmitter>> entry = iterator.next();
   Map<String, AggregatedMetricsEmitter> metricEmitters = entry.getValue().asMap();
   // +1 because we add extra metric about how many metric values did we emit in this context (see below)
   List<MetricValue> metricValues = Lists.newArrayListWithCapacity(metricEmitters.size() + 1);
   for (Map.Entry<String, AggregatedMetricsEmitter> emitterEntry : metricEmitters.entrySet()) {
    MetricValue metricValue = emitterEntry.getValue().emit();
    // skip increment by 0
    if (metricValue.getType() == MetricType.COUNTER && metricValue.getValue() == 0) {
     continue;
    }
    metricValues.add(metricValue);
   }
   if (metricValues.isEmpty()) {
    // skip if there are no metric values to send
    continue;
   }
   // number of emitted metrics
   metricValues.add(new MetricValue("metrics.emitted.count", MetricType.COUNTER, metricValues.size() + 1));
   LOG.trace("Emit metric {}", metricValues);
   return new MetricValues(entry.getKey(), timestamp, metricValues);
  }
  return endOfData();
 }
};
co.cask.cdap.api.metricsMetricValue<init>

Popular methods of MetricValue

  • getName
  • getType
  • getValue

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSystemService (Context)
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • JTextField (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • IsNull (org.hamcrest.core)
    Is the value null?
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now