當前位置: 首頁>>代碼示例>>Java>>正文


Java Metrics類代碼示例

本文整理匯總了Java中com.yammer.metrics.Metrics的典型用法代碼示例。如果您正苦於以下問題:Java Metrics類的具體用法?Java Metrics怎麽用?Java Metrics使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Metrics類屬於com.yammer.metrics包,在下文中一共展示了Metrics類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildInfluxDBReporter

import com.yammer.metrics.Metrics; //導入依賴的package包/類
private FilteredInfluxDBReporter buildInfluxDBReporter() {
    FilteredInfluxDBReporter influxDBReporter = null;
    influxDBReporter = new FilteredInfluxDBReporter(
                Metrics.defaultRegistry(),
                influxDBAddress,
                influxDBDatabase,
                influxDBRetentionPolicy,
                influxDBUsername,
                influxDBPassword,
                influxDBConsistency,
                influxDBTags,
                metricDimensions,
                Clock.defaultClock(),
                VirtualMachineMetrics.getInstance()
        );
    return influxDBReporter;
}
 
開發者ID:jasper-zhang,項目名稱:kafka-influxdb,代碼行數:18,代碼來源:KafkaInfluxDBMetricsReporter.java

示例2: mustPassAllFilters

import com.yammer.metrics.Metrics; //導入依賴的package包/類
@Test
public void mustPassAllFilters() throws Exception {
    Metrics.newCounter(this.getClass(), "counter1111").inc();
    Metrics.newCounter(this.getClass(), "counter2222").inc();
    Metrics.newCounter(this.getClass(), "meter1111").inc();

    final AnodotReporterWrapper reporter = Anodot2ReporterBuilder.builderFor(conf)
            .addFilter(whatPropertyContains("count")) // both counters pass this one
            .addFilter(whatPropertyContains("1111"))  // but only the first passes this one
            .build(Metrics.defaultRegistry());

    runReportCycle(reporter);
    verify(postRequestedFor(urlEqualTo("/anodot?token=t"))
            .withRequestBody(containing("counter1111"))
            .withRequestBody(notMatching(".*counter2222.*"))
            .withRequestBody(notMatching(".*meter1111.*"))
    );
}
 
開發者ID:kenshoo,項目名稱:anodot-metrics-bridge,代碼行數:19,代碼來源:Anodot2ReporterBuilderTest.java

示例3: init

import com.yammer.metrics.Metrics; //導入依賴的package包/類
@Override
public void init(VerifiableProperties props) {

    if(!initialized) {
        KafkaMetricsConfig metricsConfig = new KafkaMetricsConfig(props);

        InfluxDBMetricsConfig config = new InfluxDBMetricsConfig(props);
        config.addTag("brokerId", props.getString("broker.id"));

        this.reporter = new InfluxReporter(Metrics.defaultRegistry(), DEFAULT_NAME
                ,new InfluxDBClient(config), new MetricsPredicate(config.getPredicates()));

        if (props.getBoolean(InfluxDBMetricsConfig.KAFKA_INFLUX_METRICS_ENABLE, false)) {
            initialized = true;
            startReporter(metricsConfig.pollingIntervalSecs());
            LOG.info("KafkaInfluxMetricsReporter initialized.");
        }
    }
}
 
開發者ID:fhussonnois,項目名稱:kafka-influxdb-reporter,代碼行數:20,代碼來源:KafkaInfluxMetricsReporter.java

示例4: release

import com.yammer.metrics.Metrics; //導入依賴的package包/類
/**
 * Release all associated metrics.
 */
public void release()
{
    for(String name : all)
    {
        allColumnFamilyMetrics.get(name).remove(Metrics.defaultRegistry().allMetrics().get(factory.createMetricName(name)));
        Metrics.defaultRegistry().removeMetric(factory.createMetricName(name));
    }
    readLatency.release();
    writeLatency.release();
    rangeLatency.release();
    Metrics.defaultRegistry().removeMetric(factory.createMetricName("EstimatedRowSizeHistogram"));
    Metrics.defaultRegistry().removeMetric(factory.createMetricName("EstimatedColumnCountHistogram"));
    Metrics.defaultRegistry().removeMetric(factory.createMetricName("KeyCacheHitRate"));
    Metrics.defaultRegistry().removeMetric(factory.createMetricName("CoordinatorReadLatency"));
    Metrics.defaultRegistry().removeMetric(factory.createMetricName("CoordinatorScanLatency"));
    Metrics.defaultRegistry().removeMetric(factory.createMetricName("WaitingOnFreeMemtableSpace"));
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:21,代碼來源:ColumnFamilyMetrics.java

示例5: createColumnFamilyCounter

import com.yammer.metrics.Metrics; //導入依賴的package包/類
/**
 * Creates a counter that will also have a global counter thats the sum of all counters across 
 * different column families
 */
protected Counter createColumnFamilyCounter(final String name)
{
    Counter cfCounter = Metrics.newCounter(factory.createMetricName(name));
    if (register(name, cfCounter))
    {
        Metrics.newGauge(globalNameFactory.createMetricName(name), new Gauge<Long>()
        {
            public Long value()
            {
                long total = 0;
                for (Metric cfGauge : allColumnFamilyMetrics.get(name))
                {
                    total += ((Counter) cfGauge).count();
                }
                return total;
            }
        });
    }
    return cfCounter;
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:25,代碼來源:ColumnFamilyMetrics.java

示例6: addCounter

import com.yammer.metrics.Metrics; //導入依賴的package包/類
public void addCounter(String name, final Callable<Integer> provider)
{
    Metrics.newGauge(factory.createMetricName(name), new Gauge<Integer>()
    {
        public Integer value()
        {
            try
            {
                return provider.call();
            }
            catch (Exception e)
            {
                throw new RuntimeException(e);
            }
        }
    });
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:18,代碼來源:ClientMetrics.java

示例7: CommitLogMetrics

import com.yammer.metrics.Metrics; //導入依賴的package包/類
public CommitLogMetrics(final AbstractCommitLogService service, final CommitLogSegmentManager allocator)
{
    completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return service.getCompletedTasks();
        }
    });
    pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return service.getPendingTasks();
        }
    });
    totalCommitLogSize = Metrics.newGauge(factory.createMetricName("TotalCommitLogSize"), new Gauge<Long>()
    {
        public Long value()
        {
            return allocator.bytesUsed();
        }
    });
    waitingOnSegmentAllocation = Metrics.newTimer(factory.createMetricName("WaitingOnSegmentAllocation"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS);
    waitingOnCommit = Metrics.newTimer(factory.createMetricName("WaitingOnCommit"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS);
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:27,代碼來源:CommitLogMetrics.java

示例8: FileCacheMetrics

import com.yammer.metrics.Metrics; //導入依賴的package包/類
public FileCacheMetrics()
{
    hits = Metrics.newMeter(factory.createMetricName("Hits"), "hits", TimeUnit.SECONDS);
    requests = Metrics.newMeter(factory.createMetricName("Requests"), "requests", TimeUnit.SECONDS);
    hitRate = Metrics.newGauge(factory.createMetricName("HitRate"), new RatioGauge()
    {
        protected double getNumerator()
        {
            return hits.count();
        }

        protected double getDenominator()
        {
            return requests.count();
        }
    });
    size = Metrics.newGauge(factory.createMetricName("Size"), new Gauge<Long>()
    {
        public Long value()
        {
            return FileCacheService.instance.sizeInBytes();
        }
    });
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:25,代碼來源:FileCacheMetrics.java

示例9: createKeyspaceGauge

import com.yammer.metrics.Metrics; //導入依賴的package包/類
/**
 * Creates a gauge that will sum the current value of a metric for all column families in this keyspace
 * @param name
 * @param MetricValue 
 * @return Gauge&gt;Long> that computes sum of MetricValue.getValue()
 */
private <T extends Number> Gauge<Long> createKeyspaceGauge(String name, final MetricValue extractor)
{
    allMetrics.add(name);
    return Metrics.newGauge(factory.createMetricName(name), new Gauge<Long>()
    {
        public Long value()
        {
            long sum = 0;
            for (ColumnFamilyStore cf : keyspace.getColumnFamilyStores())
            {
                sum += extractor.getValue(cf.metric);
            }
            return sum;
        }
    });
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:23,代碼來源:KeyspaceMetrics.java

示例10: CQLMetrics

import com.yammer.metrics.Metrics; //導入依賴的package包/類
public CQLMetrics()
{
    regularStatementsExecuted = Metrics.newCounter(factory.createMetricName("RegularStatementsExecuted"));
    preparedStatementsExecuted = Metrics.newCounter(factory.createMetricName("PreparedStatementsExecuted"));
    preparedStatementsEvicted = Metrics.newCounter(factory.createMetricName("PreparedStatementsEvicted"));

    preparedStatementsCount = Metrics.newGauge(factory.createMetricName("PreparedStatementsCount"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return QueryProcessor.preparedStatementsCount();
        }
    });
    preparedStatementsRatio = Metrics.newGauge(factory.createMetricName("PreparedStatementsRatio"), new RatioGauge()
    {
        public double getNumerator()
        {
            return preparedStatementsExecuted.count();
        }

        public double getDenominator()
        {
            return regularStatementsExecuted.count() + preparedStatementsExecuted.count();
        }
    });
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:27,代碼來源:CQLMetrics.java

示例11: CommitLogMetrics

import com.yammer.metrics.Metrics; //導入依賴的package包/類
public CommitLogMetrics(final ICommitLogExecutorService executor, final CommitLogAllocator allocator)
{
    completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getCompletedTasks();
        }
    });
    pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getPendingTasks();
        }
    });
    totalCommitLogSize = Metrics.newGauge(factory.createMetricName("TotalCommitLogSize"), new Gauge<Long>()
    {
        public Long value()
        {
            return allocator.bytesUsed();
        }
    });
}
 
開發者ID:pgaref,項目名稱:ACaZoo,代碼行數:25,代碼來源:CommitLogMetrics.java

示例12: FileCacheMetrics

import com.yammer.metrics.Metrics; //導入依賴的package包/類
public FileCacheMetrics()
{
    hits = Metrics.newMeter(new MetricName(FileCacheService.class, "Hits"), "hits", TimeUnit.SECONDS);
    requests = Metrics.newMeter(new MetricName(FileCacheService.class, "Requests"), "requests", TimeUnit.SECONDS);
    hitRate = Metrics.newGauge(new MetricName(FileCacheService.class, "HitRate"), new RatioGauge()
    {
        protected double getNumerator()
        {
            return hits.count();
        }

        protected double getDenominator()
        {
            return requests.count();
        }
    });
    size = Metrics.newGauge(new MetricName(FileCacheService.class, "Size"), new Gauge<Long>()
    {
        public Long value()
        {
            return FileCacheService.instance.sizeInBytes();
        }
    });
}
 
開發者ID:pgaref,項目名稱:ACaZoo,代碼行數:25,代碼來源:FileCacheMetrics.java

示例13: init

import com.yammer.metrics.Metrics; //導入依賴的package包/類
@Override
public void init(Configuration queryExecutorConfig, DataManager dataManager, ServerMetrics serverMetrics)
    throws ConfigurationException {
  _serverMetrics = serverMetrics;
  _queryExecutorConfig = new QueryExecutorConfig(queryExecutorConfig);
  _instanceDataManager = (InstanceDataManager) dataManager;
  if (_queryExecutorConfig.getTimeOut() > 0) {
    _defaultTimeOutMs = _queryExecutorConfig.getTimeOut();
  }
  LOGGER.info("Default timeout for query executor : {}", _defaultTimeOutMs);
  LOGGER.info("Trying to build SegmentPrunerService");
  if (_segmentPrunerService == null) {
    _segmentPrunerService = new SegmentPrunerServiceImpl(_queryExecutorConfig.getPrunerConfig());
  }
  LOGGER.info("Trying to build QueryPlanMaker");
  _planMaker = new InstancePlanMakerImplV2();
  LOGGER.info("Trying to build QueryExecutorTimer");
  if (_queryExecutorTimer == null) {
    _queryExecutorTimer =
        Metrics.newTimer(new MetricName(Domain, "timer", "query-executor-time-"), TimeUnit.MILLISECONDS,
            TimeUnit.SECONDS);
  }
}
 
開發者ID:Hanmourang,項目名稱:Pinot,代碼行數:24,代碼來源:ServerQueryExecutorV1Impl.java

示例14: getStats

import com.yammer.metrics.Metrics; //導入依賴的package包/類
@ManagedAttribute
public Map<String, Object> getStats() {
    Map<String, Object> stats = new HashMap<String, Object>();
    
    MetricsRegistry registry = Metrics.defaultRegistry();
    for (Entry<MetricName, Metric> e : registry.allMetrics().entrySet()) {
        MetricName name = e.getKey();
        Metric metric = e.getValue();
        
        if (metric instanceof Meter) {
            Meter m = (Meter) metric;
            stats.put(name.toString(), new MeterPOJO(m));
        } else if (metric instanceof Gauge) {
            Gauge<?> g = (Gauge<?>) metric;
            stats.put(name.toString(), g.value());
        }
    }
    
    return stats;
}
 
開發者ID:pulsarIO,項目名稱:jetstream,代碼行數:21,代碼來源:KafkaMetrics.java

示例15: register

import com.yammer.metrics.Metrics; //導入依賴的package包/類
@PostConstruct
public void register() {
    mailTransactions =
            Metrics.newMeter(metricName("mailTransactions"),
                    "transactions", TimeUnit.MINUTES);
    rcptCommands =
            Metrics.newMeter(metricName("rcptCommands"), "commands",
                    TimeUnit.MINUTES);
    dataCommands =
            Metrics.newMeter(metricName("dataCommands"), "commands",
                    TimeUnit.MINUTES);
    acceptedMessages =
            Metrics.newMeter(metricName("acceptedMessages"), "messages",
                    TimeUnit.MINUTES);
    messageRecipients =
            Metrics.newMeter(metricName("messageRecipients"), "recipients",
                    TimeUnit.MINUTES);
}
 
開發者ID:hontvari,項目名稱:mireka,代碼行數:19,代碼來源:IncomingSmtpSummary.java


注:本文中的com.yammer.metrics.Metrics類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。