本文整理了Java中com.netflix.spectator.api.Registry.timer
方法的一些代码示例,展示了Registry.timer
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.timer
方法的具体详情如下:
包路径:com.netflix.spectator.api.Registry
类名称:Registry
方法名:timer
[英]Measures the time taken for short tasks.
[中]测量短任务所需的时间。
代码示例来源:origin: Netflix/servo
private Timer get() {
Timer t = timer;
if (t == null) {
t = registry.timer(id);
timer = t;
}
return t;
}
代码示例来源:origin: Netflix/spectator
@Test
public void correctTypeForTimersStream() {
Registry r = newRegistry(5, false);
r.timer("a").record(1, TimeUnit.MICROSECONDS);
r.timer("b").record(1, TimeUnit.MICROSECONDS);
Assertions.assertEquals(2, r.timers().count());
Assertions.assertEquals(2, r.stream().filter(m -> m instanceof Timer).count());
}
代码示例来源:origin: Netflix/conductor
private static Timer getTimer(String name, String...additionalTags) {
String key = className + "." + name + "." + Joiner.on(",").join(additionalTags);
return monitors.computeIfAbsent(key, k -> {
List<Tag> tagList = getTags(additionalTags);
tagList.add(new BasicTag("unit", TimeUnit.MILLISECONDS.name()));
return registry.timer(name, tagList);
});
}
代码示例来源:origin: spinnaker/kayenta
registry.timer(id).record(
getNanoTime() - ((Long) request.getAttribute(TIMER_ATTRIBUTE)), TimeUnit.NANOSECONDS
);
代码示例来源:origin: spinnaker/kayenta
private List<InfluxDbResult> queryInfluxdb(InfluxDbRemoteService remoteService, String metricSetName, String query) {
long startTime = registry.clock().monotonicTime();
List<InfluxDbResult> influxDbResults;
try {
influxDbResults = remoteService.query(metricSetName, query);
} finally {
long endTime = registry.clock().monotonicTime();
Id influxDbFetchTimerId = registry.createId("influxdb.fetchTime");
registry.timer(influxDbFetchTimerId).record(endTime - startTime, TimeUnit.NANOSECONDS);
}
return influxDbResults;
}
代码示例来源:origin: spinnaker/kayenta
registry.timer(prometheusFetchTimerId).record(endTime - startTime, TimeUnit.NANOSECONDS);
代码示例来源:origin: com.netflix.genie/genie-web
/**
* Constructor.
*
* @param registry The registry to use
*/
public PingFederateValidator(final Registry registry) {
this.jwtValidationTimer = registry.timer("genie.security.oauth2.pingFederate.jwt.validation.timer");
}
代码示例来源:origin: spinnaker/kayenta
registry.timer(stackdriverFetchTimerId).record(endTime - startTime, TimeUnit.NANOSECONDS);
代码示例来源:origin: spinnaker/kayenta
} finally {
long end = registry.clock().monotonicTime();
registry.timer("atlas.fetchTime").record(end - start, TimeUnit.NANOSECONDS);
代码示例来源:origin: Netflix/spectator
/** Create a new instance. */
PercentileTimer(Registry registry, Id id, long min, long max) {
this.registry = registry;
this.id = id;
this.timer = registry.timer(id);
this.min = min;
this.max = max;
this.counters = new AtomicReferenceArray<>(PercentileBuckets.length());
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/** Create a new instance. */
Stats(Registry registry, String id) {
this.registry = registry;
activeCount = PolledMeter.using(registry)
.withId(newId(registry, id, "activeThreads"))
.monitorValue(new AtomicInteger());
taskExecutionTime = registry.timer(newId(registry, id, "taskExecutionTime"));
taskExecutionDelay = registry.timer(newId(registry, id, "taskExecutionDelay"));
skipped = registry.counter(newId(registry, id, "skipped"));
uncaughtExceptionsId = newId(registry, id, "uncaughtExceptions");
}
代码示例来源:origin: Netflix/metacat
private Timer createTimer(final Registry registry, final String requestTag) {
final HashMap<String, String> tags = new HashMap<>();
tags.put("request", requestTag);
return registry.timer(registry.createId(HiveMetrics.TimerFastHiveRequest.getMetricName()).withTags(tags));
}
代码示例来源:origin: Netflix/metacat
void recordTime(final SNSMessage<?> message, final String timeName) {
final Timer timer = this.registry.timer(
timeName,
Metrics.TagEventsType.getMetricName(),
message.getClass().getName()
);
timer.record(this.registry.clock().wallTime() - message.getTimestamp(), TimeUnit.MILLISECONDS);
}
代码示例来源:origin: Netflix/spectator
private Timer newTimer() {
List<Timer> ts = registries.stream()
.map(r -> r.timer(id))
.collect(Collectors.toList());
return new CompositeTimer(new DefaultId("foo"), clock, ts);
}
代码示例来源:origin: Netflix/spectator
private void assertCountEquals(Timer t, long expected) {
Assertions.assertEquals(t.count(), expected);
for (Registry r : registries) {
Assertions.assertEquals(r.timer(id).count(), expected);
}
}
代码示例来源:origin: Netflix/spectator
private void assertTotalEquals(Timer t, long expected) {
Assertions.assertEquals(t.totalTime(), expected);
for (Registry r : registries) {
Assertions.assertEquals(r.timer(id).totalTime(), expected);
}
}
代码示例来源:origin: Netflix/spectator
@Test
public void testDistributionSummaryBadTypeAccess() {
Assertions.assertThrows(IllegalStateException.class, () -> {
Registry r = newRegistry(5, true);
r.distributionSummary(r.createId("foo")).count();
r.timer(r.createId("foo")).count();
});
}
代码示例来源:origin: Netflix/spectator
@Test
public void testTimerBadTypeAccess() {
Assertions.assertThrows(IllegalStateException.class, () -> {
Registry r = newRegistry(5, true);
r.timer(r.createId("foo")).count();
r.counter(r.createId("foo")).count();
});
}
代码示例来源:origin: Netflix/spectator
@Test
public void validateRegistryOk() {
Id id = registry.createId(IpcMetric.clientCall.metricName())
.withTag(IpcTagKey.owner.tag("test"))
.withTag(IpcResult.success)
.withTag(IpcStatus.success)
.withTag(IpcAttempt.initial)
.withTag(IpcTagKey.attemptFinal.key(), true);
registry.timer(id).record(Duration.ofSeconds(42));
IpcMetric.validate(registry);
}
代码示例来源:origin: Netflix/spectator
@Test
public void testTimerBadTypeAccessNoThrow() {
Registry r = newRegistry(5, false);
r.timer(r.createId("foo")).count();
Counter c = r.counter(r.createId("foo"));
c.increment();
Assertions.assertEquals(c.count(), 0L);
}
内容来源于网络,如有侵权,请联系作者删除!