本文整理了Java中com.yammer.metrics.Metrics.newCounter()
方法的一些代码示例,展示了Metrics.newCounter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metrics.newCounter()
方法的具体详情如下:
包路径:com.yammer.metrics.Metrics
类名称:Metrics
方法名:newCounter
[英]Creates a new com.yammer.metrics.core.Counter and registers it under the given metric name.
[中]创建一个新的com。亚默。韵律学。果心计数器,并在给定的度量名称下进行注册。
代码示例来源:origin: apache/incubator-pinot
/**
*
* Return an existing counter if
* (a) A counter already exist with the same metric name.
* Otherwise, creates a new meter and registers
*
* @param registry MetricsRegistry
* @param name metric name
* @return Counter
*/
public static Counter newCounter(MetricsRegistry registry, MetricName name) {
if (registry != null) {
return registry.newCounter(name);
} else {
return Metrics.newCounter(name);
}
}
代码示例来源:origin: lealone/Lealone
/**
* Create metrics for given ThreadPoolExecutor.
*
* @param executor Thread pool
* @param path Type of thread pool
* @param poolName Name of thread pool to identify metrics
*/
public ThreadPoolMetrics(final ThreadPoolExecutor executor, String path, String poolName) {
this.factory = new ThreadPoolMetricNameFactory("ThreadPools", path, poolName);
activeTasks = Metrics.newGauge(factory.createMetricName("ActiveTasks"), new Gauge<Integer>() {
public Integer value() {
return executor.getActiveCount();
}
});
totalBlocked = Metrics.newCounter(factory.createMetricName("TotalBlockedTasks"));
currentBlocked = Metrics.newCounter(factory.createMetricName("CurrentlyBlockedTasks"));
completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>() {
public Long value() {
return executor.getCompletedTaskCount();
}
});
pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>() {
public Long value() {
return executor.getTaskCount() - executor.getCompletedTaskCount();
}
});
}
代码示例来源:origin: addthis/hydra
public CountingHealthCheck(int maxFailures, String meterName, boolean resetOnSuccess) {
super(maxFailures);
this.failedCheckCounter = Metrics.newCounter(CountingHealthCheck.class, meterName, null);
this.resetOnSuccess = resetOnSuccess;
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server
public Counter load(InetAddress address)
{
return Metrics.newCounter(factory.createMetricName("Hints_created-" + address.getHostAddress().replace(':', '.')));
}
});
代码示例来源:origin: com.wavefront/proxy
public HistogramLineIngester(Collection<ChannelHandler> handlers, int port) {
this.handlers = new ArrayList<>(handlers);
this.port = port;
this.connectionsAccepted = Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted",
"port", String.valueOf(port)));
this.connectionsIdleClosed = Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed",
"port", String.valueOf(port)));
}
代码示例来源:origin: com.wavefront/java-lib
private void initMetrics(int port) {
this.connectionsAccepted = Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted",
"port", String.valueOf(port)));
this.connectionsIdleClosed = Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed",
"port", String.valueOf(port)));
}
代码示例来源:origin: com.wavefront/proxy
public RawLogsIngester(LogsIngester logsIngester, int port, Supplier<Long> now) {
this.logsIngester = logsIngester;
this.port = port;
this.now = now;
this.received = Metrics.newCounter(new MetricName("logsharvesting", "", "raw-received"));
this.connectionsAccepted = Metrics.newCounter(new TaggedMetricName("listeners", "connections.accepted",
"port", String.valueOf(port)));
this.connectionsIdleClosed = Metrics.newCounter(new TaggedMetricName("listeners", "connections.idle.closed",
"port", String.valueOf(port)));
}
代码示例来源:origin: com.wavefront/proxy
public ReportPointTimestampInRangeFilter(final int hoursInPastAllowed, final int hoursInFutureAllowed) {
this.hoursInPastAllowed = hoursInPastAllowed;
this.hoursInFutureAllowed = hoursInFutureAllowed;
this.outOfRangePointTimes = Metrics.newCounter(new MetricName("point", "", "badtime"));
}
代码示例来源:origin: rackerlabs/atom-hopper
private void incrementCounterForFeed(String feedName) {
if (!counterMap.containsKey(feedName)) {
synchronized (counterMap) {
if (!counterMap.containsKey(feedName)) {
Counter counter = Metrics.newCounter(MongodbFeedPublisher.class, "entries-created-for-" + feedName);
counterMap.put(feedName, counter);
}
}
}
counterMap.get(feedName).inc();
}
}
代码示例来源:origin: rackerlabs/atom-hopper
private void incrementCounterForFeed(String feedName) {
if (!counterMap.containsKey(feedName)) {
synchronized (counterMap) {
if (!counterMap.containsKey(feedName)) {
Counter counter = Metrics.newCounter( JdbcFeedPublisher.class, "entries-created-for-" + feedName );
counterMap.put(feedName, counter);
}
}
}
counterMap.get(feedName).inc();
}
代码示例来源:origin: rackerlabs/atom-hopper
private void incrementCounterForFeed(String feedName) {
if (!counterMap.containsKey(feedName)) {
synchronized (counterMap) {
if (!counterMap.containsKey(feedName)) {
Counter counter = Metrics.newCounter(PostgresFeedPublisher.class, "entries-created-for-" + feedName);
counterMap.put(feedName, counter);
}
}
}
counterMap.get(feedName).inc();
}
}
代码示例来源:origin: rackerlabs/atom-hopper
private void incrementCounterForFeed(String feedName) {
if (!counterMap.containsKey(feedName)) {
synchronized (counterMap) {
if (!counterMap.containsKey(feedName)) {
Counter counter = Metrics.newCounter(HibernateFeedPublisher.class, "entries-created-for-" + feedName);
counterMap.put(feedName, counter);
}
}
}
counterMap.get(feedName).inc();
}
}
代码示例来源:origin: wavefrontHQ/java
public ReportPointTimestampInRangeFilter(final int hoursInPastAllowed, final int hoursInFutureAllowed) {
this.hoursInPastAllowed = hoursInPastAllowed;
this.hoursInFutureAllowed = hoursInFutureAllowed;
this.outOfRangePointTimes = Metrics.newCounter(new MetricName("point", "", "badtime"));
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server
public StreamingMetrics(final InetAddress peer)
{
MetricNameFactory factory = new DefaultNameFactory("Streaming", peer.getHostAddress().replace(':', '.'));
incomingBytes = Metrics.newCounter(factory.createMetricName("IncomingBytes"));
outgoingBytes= Metrics.newCounter(factory.createMetricName("OutgoingBytes"));
}
}
代码示例来源:origin: com.wavefront/proxy
public ReportSourceTagHandlerImpl(final String handle, final int blockedItemsPerBatch,
final Collection<SenderTask> senderTasks) {
super(ReportableEntityType.SOURCE_TAG, handle, blockedItemsPerBatch, new ReportSourceTagSerializer(), senderTasks);
this.attemptedCounter = Metrics.newCounter(new MetricName("sourceTags." + handle, "", "sent"));
this.queuedCounter = Metrics.newCounter(new MetricName("sourceTags." + handle, "", "queued"));
statisticOutputExecutor.scheduleAtFixedRate(this::printStats, 10, 10, TimeUnit.SECONDS);
statisticOutputExecutor.scheduleAtFixedRate(this::printTotal, 1, 1, TimeUnit.MINUTES);
}
代码示例来源:origin: wavefrontHQ/java
public ReportSourceTagHandlerImpl(final String handle, final int blockedItemsPerBatch,
final Collection<SenderTask> senderTasks) {
super(ReportableEntityType.SOURCE_TAG, handle, blockedItemsPerBatch, new ReportSourceTagSerializer(), senderTasks);
this.attemptedCounter = Metrics.newCounter(new MetricName("sourceTags." + handle, "", "sent"));
this.queuedCounter = Metrics.newCounter(new MetricName("sourceTags." + handle, "", "queued"));
statisticOutputExecutor.scheduleAtFixedRate(this::printStats, 10, 10, TimeUnit.SECONDS);
statisticOutputExecutor.scheduleAtFixedRate(this::printTotal, 1, 1, TimeUnit.MINUTES);
}
代码示例来源:origin: com.senseidb/sensei-core
private void initCounters() {
for (int currentPartition : _core.getPartitions()) {
partitionCalls.put(
currentPartition,
Metrics.newCounter(AbstractSenseiCoreService.class, "partitionCallsForPartition"
+ currentPartition + "andNode" + _core.getNodeId()));
}
}
}
代码示例来源:origin: com.wavefront/proxy
public FilebeatIngester(LogsIngester logsIngester, Supplier<Long> currentMillis) {
this.logsIngester = logsIngester;
this.received = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-received"));
this.malformed = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-malformed"));
this.drift = Metrics.newHistogram(new MetricName("logsharvesting", "", "filebeat-drift"));
this.currentMillis = currentMillis;
}
代码示例来源:origin: wavefrontHQ/java
public FilebeatIngester(LogsIngester logsIngester, Supplier<Long> currentMillis) {
this.logsIngester = logsIngester;
this.received = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-received"));
this.malformed = Metrics.newCounter(new MetricName("logsharvesting", "", "filebeat-malformed"));
this.drift = Metrics.newHistogram(new MetricName("logsharvesting", "", "filebeat-drift"));
this.currentMillis = currentMillis;
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server
public CASClientRequestMetrics(String scope) {
super(scope);
contention = Metrics.newHistogram(factory.createMetricName("ContentionHistogram"), true);
conditionNotMet = Metrics.newCounter(factory.createMetricName("ConditionNotMet"));
unfinishedCommit = Metrics.newCounter(factory.createMetricName("UnfinishedCommit"));
}
内容来源于网络,如有侵权,请联系作者删除!