本文整理了Java中com.netflix.spectator.api.Registry.collectionSize
方法的一些代码示例,展示了Registry.collectionSize
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.collectionSize
方法的具体详情如下:
包路径:com.netflix.spectator.api.Registry
类名称:Registry
方法名:collectionSize
[英]Tells the registry to regularly poll the collection and report its size as a gauge. The registration will keep a weak reference to the collection so it will not prevent garbage collection. The collection implementation used should be thread safe. Note that calling java.util.Collection#size() can be expensive for some collection implementations and should be considered before registering. For more information see #gauge(Id,Object,ToDoubleFunction).
[中]告诉注册中心定期对集合进行投票,并报告其大小。注册将保留对收集的弱引用,因此不会阻止垃圾收集。使用的集合实现应该是线程安全的。请注意,调用java。util。Collection#size()对于某些集合实现来说可能很昂贵,在注册之前应该考虑。有关更多信息,请参见#仪表(Id、对象、ToDoubleFunction)。
代码示例来源:origin: org.springframework.metrics/spring-metrics
@Override
public <T extends Collection<?>> T collectionSize(Id id, T collection) {
return composite.collectionSize(id, collection);
}
代码示例来源:origin: org.springframework.metrics/spring-metrics
@Override
public <T extends Collection<?>> T collectionSize(String name, T collection) {
return composite.collectionSize(name, collection);
}
代码示例来源:origin: Netflix/spectator
/**
* Tells the registry to regularly poll the collection and report its size as a gauge.
* See {@link #collectionSize(Id, Collection)} for more information.
*
* @param name
* Name of the metric being registered.
* @param collection
* Thread-safe implementation of {@link Collection} used to access the value.
* @return
* The collection that was passed in so the registration can be done as part of an assignment
* statement.
* @deprecated
* Use {@link PolledMeter} instead. This method has been deprecated to help
* reduce confusion between active gauges that are explicitly updated by the
* user and passive gauges that are polled in the background. Going forward
* the registry methods will only be used for the core types directly updated
* by the user. Other patterns such as {@link PolledMeter}s will be handled
* separately. Scheduled to be removed in 2.0.
*/
@Deprecated
default <T extends Collection<?>> T collectionSize(String name, T collection) {
return collectionSize(createId(name), collection);
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Tells the registry to regularly poll the collection and report its size as a gauge.
* See {@link #collectionSize(Id, Collection)} for more information.
*
* @param name
* Name of the metric being registered.
* @param collection
* Thread-safe implementation of {@link Collection} used to access the value.
* @return
* The collection that was passed in so the registration can be done as part of an assignment
* statement.
* @deprecated
* Use {@link PolledMeter} instead. This method has been deprecated to help
* reduce confusion between active gauges that are explicitly updated by the
* user and passive gauges that are polled in the background. Going forward
* the registry methods will only be used for the core types directly updated
* by the user. Other patterns such as {@link PolledMeter}s will be handled
* separately. Scheduled to be removed in 2.0.
*/
@Deprecated
default <T extends Collection<?>> T collectionSize(String name, T collection) {
return collectionSize(createId(name), collection);
}
代码示例来源:origin: Netflix/metacat
/**
* Register the pool properties.
* @param registry Spectator registry
* @param name name of the monitor
* @param pool thread pool
*/
public static void registerThreadPool(final Registry registry,
final String name,
final ThreadPoolExecutor pool) {
registry.gauge(NAME_MONITORED_POOL + name + "_" + "activeCount", pool, ThreadPoolExecutor::getActiveCount);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "completedTaskCount", pool,
ThreadPoolExecutor::getCompletedTaskCount);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "corePoolSize", pool, ThreadPoolExecutor::getCorePoolSize);
registry
.gauge(NAME_MONITORED_POOL + name + "_" + "maximumPoolSize", pool, ThreadPoolExecutor::getMaximumPoolSize);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "poolSize", pool, ThreadPoolExecutor::getPoolSize);
registry.collectionSize(NAME_MONITORED_POOL + name + "_" + "queueSize", pool.getQueue());
registry.gauge(NAME_MONITORED_POOL + name + "_" + "taskCount", pool, ThreadPoolExecutor::getTaskCount);
}
}
代码示例来源:origin: com.netflix.metacat/metacat-common-server
/**
* Register the pool properties.
* @param registry Spectator registry
* @param name name of the monitor
* @param pool thread pool
*/
public static void registerThreadPool(final Registry registry,
final String name,
final ThreadPoolExecutor pool) {
registry.gauge(NAME_MONITORED_POOL + name + "_" + "activeCount", pool, ThreadPoolExecutor::getActiveCount);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "completedTaskCount", pool,
ThreadPoolExecutor::getCompletedTaskCount);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "corePoolSize", pool, ThreadPoolExecutor::getCorePoolSize);
registry
.gauge(NAME_MONITORED_POOL + name + "_" + "maximumPoolSize", pool, ThreadPoolExecutor::getMaximumPoolSize);
registry.gauge(NAME_MONITORED_POOL + name + "_" + "poolSize", pool, ThreadPoolExecutor::getPoolSize);
registry.collectionSize(NAME_MONITORED_POOL + name + "_" + "queueSize", pool.getQueue());
registry.gauge(NAME_MONITORED_POOL + name + "_" + "taskCount", pool, ThreadPoolExecutor::getTaskCount);
}
}
代码示例来源:origin: Netflix/spectator
@Test
public void testCollectionSizeHelpers() {
Registry r = newRegistry(true, 10000);
LinkedBlockingDeque<String> q1 = new LinkedBlockingDeque<>();
LinkedBlockingDeque<String> q2 = r.collectionSize("queueSize", q1);
Assertions.assertSame(q1, q2);
Id id = r.createId("queueSize");
assertGaugeValue(r, id, 0.0);
q2.push("foo");
assertGaugeValue(r, id, 1.0);
}
内容来源于网络,如有侵权,请联系作者删除!