本文整理了Java中com.netflix.spectator.api.Registry.counter
方法的一些代码示例,展示了Registry.counter
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.counter
方法的具体详情如下:
包路径:com.netflix.spectator.api.Registry
类名称:Registry
方法名:counter
[英]Measures the rate of some activity.
[中]测量某些活动的速率。
代码示例来源:origin: Netflix/zuul
public ClientResponseWriter(RequestCompleteHandler requestCompleteHandler, Registry registry) {
this.requestCompleteHandler = requestCompleteHandler;
this.responseBeforeReceivedLastContentCounter = registry.counter("server.http.requests.responseBeforeReceivedLastContent");
}
代码示例来源:origin: Netflix/zuul
public PassportLoggingHandler(Registry spectatorRegistry)
{
incompleteProxySessionCounter = spectatorRegistry.counter("server.http.session.incomplete");
}
代码示例来源:origin: Netflix/zuul
protected static void incrementExceptionCounter(Throwable throwable, String handler) {
registry.counter("server.connection.exception",
"handler", handler,
"id", throwable.getClass().getSimpleName())
.increment();
}
代码示例来源:origin: Netflix/zuul
protected static void incrementExceptionCounter(Throwable throwable) {
registry.counter("server.connection.exception",
"handler", "Http2ConnectionCloseHandler",
"id", throwable.getClass().getSimpleName())
.increment();
}
代码示例来源:origin: Netflix/zuul
public ClientResponseWriter(RequestCompleteHandler requestCompleteHandler, Registry registry) {
this.requestCompleteHandler = requestCompleteHandler;
this.responseBeforeReceivedLastContentCounter = registry.counter("server.http.requests.responseBeforeReceivedLastContent");
}
代码示例来源:origin: Netflix/zuul
public PassportLoggingHandler(Registry spectatorRegistry)
{
incompleteProxySessionCounter = spectatorRegistry.counter("server.http.session.incomplete");
}
代码示例来源:origin: Netflix/conductor
private static Counter getCounter(String name, String...additionalTags) {
String key = className + "." + name + "." + Joiner.on(",").join(additionalTags);
return errors.computeIfAbsent(key, k -> {
List<Tag> tags = getTags(additionalTags);
return registry.counter(name, tags);
});
}
代码示例来源:origin: Netflix/conductor
private static Counter getCounter(String className, String name, String... additionalTags) {
Map<String, String> tags = toMap(className, additionalTags);
return counters.computeIfAbsent(name, s -> new ConcurrentHashMap<>()).computeIfAbsent(tags, t -> {
Id id = registry.createId(name, tags);
return registry.counter(id);
});
}
代码示例来源:origin: Netflix/zuul
public HttpMetricsChannelHandler(Registry registry, String name, String id)
{
super();
this.registry = registry;
this.currentRequestsGauge = this.registry.gauge(this.registry.createId(name + ".http.requests.current", "id", id));
this.unSupportedPipeliningCounter = this.registry.counter(name + ".http.requests.pipelining.dropped", "id", id);
}
代码示例来源:origin: Netflix/zuul
protected static void incrementErrorCounter(Registry registry, String counterName, String metricId, Http2Exception h2e)
{
String h2Error = h2e.error() != null ? h2e.error().name() : "NA";
String exceptionName = h2e.getClass().getSimpleName();
registry.counter(counterName,
"id", metricId,
"error", h2Error,
"exception", exceptionName)
.increment();
}
代码示例来源:origin: Netflix/zuul
protected static void incrementExceptionCounter(Throwable throwable) {
registry.counter("server.connection.exception",
"handler", "Http2ConnectionCloseHandler",
"id", throwable.getClass().getSimpleName())
.increment();
}
代码示例来源:origin: Netflix/zuul
protected static void incrementExceptionCounter(Throwable throwable, String handler) {
registry.counter("server.connection.exception",
"handler", handler,
"id", throwable.getClass().getSimpleName())
.increment();
}
代码示例来源:origin: Netflix/zuul
protected static void incrementCounter(Registry registry, String counterName, String metricId, Http2Frame frame)
{
long errorCode;
if (frame instanceof Http2ResetFrame) {
errorCode = ((Http2ResetFrame) frame).errorCode();
}
else if (frame instanceof Http2GoAwayFrame) {
errorCode = ((Http2GoAwayFrame) frame).errorCode();
}
else {
errorCode = -1;
}
registry.counter(counterName,
"id", metricId,
"frame", frame.name(),
"error_code", Long.toString(errorCode))
.increment();
}
代码示例来源:origin: Netflix/zuul
public HttpMetricsChannelHandler(Registry registry, String name, String id)
{
super();
this.registry = registry;
this.currentRequestsGauge = this.registry.gauge(this.registry.createId(name + ".http.requests.current", "id", id));
this.unSupportedPipeliningCounter = this.registry.counter(name + ".http.requests.pipelining.dropped", "id", id);
}
代码示例来源:origin: Netflix/zuul
protected static void incrementErrorCounter(Registry registry, String counterName, String metricId, Http2Exception h2e)
{
String h2Error = h2e.error() != null ? h2e.error().name() : "NA";
String exceptionName = h2e.getClass().getSimpleName();
registry.counter(counterName,
"id", metricId,
"error", h2Error,
"exception", exceptionName)
.increment();
}
代码示例来源:origin: Netflix/servo
@Test
public void testBasicCounterIncrementAmount() {
BasicCounter c = new BasicCounter(CONFIG);
register(c);
c.increment(42);
assertEquals(42, registry.counter(ID).count());
}
代码示例来源:origin: Netflix/zuul
protected static void incrementCounter(Registry registry, String counterName, String metricId, Http2Frame frame)
{
long errorCode;
if (frame instanceof Http2ResetFrame) {
errorCode = ((Http2ResetFrame) frame).errorCode();
}
else if (frame instanceof Http2GoAwayFrame) {
errorCode = ((Http2GoAwayFrame) frame).errorCode();
}
else {
errorCode = -1;
}
registry.counter(counterName,
"id", metricId,
"frame", frame.name(),
"error_code", Long.toString(errorCode))
.increment();
}
代码示例来源:origin: Netflix/servo
@Test
public void testContextualTimerRecordMillis() {
TagList context = BasicTagList.of("a", "1");
ContextualTimer d = new ContextualTimer(CONFIG, () -> context, BasicTimer::new);
d.record(42, TimeUnit.NANOSECONDS);
Id id = ID.withTag("unit", "MILLISECONDS").withTag("a", "1");
assertEquals(1, registry.counter(id.withTag(Statistic.count)).count());
assertEquals(42e-6, registry.counter(id.withTag(Statistic.totalTime)).actualCount(), 1e-12);
assertEquals(42e-6 * 42e-6, registry.counter(id.withTag(Statistic.totalOfSquares)).actualCount(), 1e-12);
assertEquals(42e-6, registry.maxGauge(id.withTag(Statistic.max)).value(), 1e-12);
}
代码示例来源:origin: Netflix/servo
@Test
public void testBasicDistributionSummaryRecord() {
BasicDistributionSummary d = new BasicDistributionSummary(CONFIG);
register(d);
d.record(42);
assertEquals(1, registry.counter(ID.withTag(Statistic.count)).count());
assertEquals(42, registry.counter(ID.withTag(Statistic.totalAmount)).count());
assertEquals(42.0, registry.maxGauge(ID.withTag(Statistic.max)).value(), 1e-12);
}
代码示例来源:origin: Netflix/servo
@Test
public void testAnnotatedCounter() {
AnnotateExample ex = new AnnotateExample("foo");
PolledMeter.update(registry);
Id id = registry.createId("counter")
.withTag("class", "AnnotateExample")
.withTag("level", "INFO")
.withTag("id", "foo");
assertEquals(1, registry.counter(id).count());
}
内容来源于网络,如有侵权,请联系作者删除!