コード例 #1
0
 MetricsSourceAdapter(
     String prefix,
     String name,
     String description,
     MetricsSource source,
     Iterable<MetricsTag> injectedTags,
     MetricsFilter recordFilter,
     MetricsFilter metricFilter,
     int jmxCacheTTL) {
   this.prefix = Contracts.checkNotNull(prefix, "prefix");
   this.name = Contracts.checkNotNull(name, "name");
   this.source = Contracts.checkNotNull(source, "source");
   attrCache = new HashMap<String, Attribute>();
   infoBuilder = new MBeanInfoBuilder(name, description);
   this.injectedTags = injectedTags;
   this.recordFilter = recordFilter;
   this.metricFilter = metricFilter;
   this.jmxCacheTTL = Contracts.checkArg(jmxCacheTTL, jmxCacheTTL > 0, "jmxCacheTTL");
 }
コード例 #2
0
  MetricsSinkAdapter(
      String name,
      String description,
      MetricsSink sink,
      String context,
      MetricsFilter sourceFilter,
      MetricsFilter recordFilter,
      MetricsFilter metricFilter,
      int period,
      int queueCapacity,
      int retryDelay,
      float retryBackoff,
      int retryCount) {
    this.name = Contracts.checkNotNull(name, "name");
    this.description = description;
    this.sink = Contracts.checkNotNull(sink, "sink object");
    this.context = context;
    this.sourceFilter = sourceFilter;
    this.recordFilter = recordFilter;
    this.metricFilter = metricFilter;
    this.period = Contracts.checkArg(period, period > 0, "period");
    firstRetryDelay = Contracts.checkArg(retryDelay, retryDelay > 0, "retry delay");
    this.retryBackoff = Contracts.checkArg(retryBackoff, retryBackoff > 1, "backoff factor");
    oobPutTimeout = (long) (firstRetryDelay * Math.pow(retryBackoff, retryCount) * 1000);
    this.retryCount = retryCount;
    this.queue =
        new SinkQueue<MetricsBuffer>(
            Contracts.checkArg(queueCapacity, queueCapacity > 0, "queue capacity"));
    latency =
        registry.newStat("sink." + name + ".latency", "Sink end to end latency", "ops", "time");
    dropped = registry.newCounter("sink." + name + ".dropped", "Dropped updates per sink", 0);
    qsize = registry.newGauge("sink." + name + ".qsize", "Queue size", 0);

    sinkThread =
        new Thread() {
          @Override
          public void run() {
            publishMetricsFromQueue();
          }
        };
    sinkThread.setName(name);
    sinkThread.setDaemon(true);
  }