当前位置: 首页>>代码示例>>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;未经允许,请勿转载。