本文整理了Java中com.netflix.spectator.api.Clock
类的一些代码示例,展示了Clock
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clock
类的具体详情如下:
包路径:com.netflix.spectator.api.Clock
类名称:Clock
[英]A timing source that can be used to access the current wall time as well as a high resolution monotonic time to measuring elapsed times. Most of the time the #SYSTEM implementation that calls the builtin java methods is probably the right one to use. Other implementations would typically only get used for unit tests or other cases where precise control of the clock is needed.
[中]一种定时源,可用于访问当前壁时间以及测量经过时间的高分辨率单调时间。大多数时候,调用内置java方法的#系统实现可能是正确的。其他实现通常只用于单元测试或其他需要精确控制时钟的情况。
代码示例来源:origin: apache/servicecomb-java-chassis
public PolledEvent poll(long secondInterval) {
long msNow = clock.wallTime();
List<Meter> meters = new ArrayList<>();
List<Measurement> measurements = new ArrayList<>();
for (Registry registry : registries) {
SpectatorUtils.removeExpiredMeters(registry);
for (Meter meter : registry) {
if (meter instanceof PeriodMeter) {
((PeriodMeter) meter).calcMeasurements(msNow, secondInterval);
}
meters.add(meter);
meter.measure().forEach(measurements::add);
}
}
return new PolledEvent(meters, measurements);
}
}
代码示例来源: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: Netflix/spectator
/** Create a new instance. */
AtlasMeter(Id id, Clock clock, long ttl) {
this.id = id;
this.clock = clock;
this.ttl = ttl;
lastUpdated = clock.wallTime();
}
代码示例来源:origin: spinnaker/kayenta
long startTime = registry.clock().monotonicTime();
List<PrometheusResults> prometheusResultsList;
canaryScope.getStep());
} finally {
long endTime = registry.clock().monotonicTime();
代码示例来源:origin: Netflix/spectator
/**
* Updates the last updated timestamp for the meter to indicate it is active and should
* not be considered expired.
*/
void updateLastModTime() {
lastUpdated = clock.wallTime();
}
代码示例来源:origin: Netflix/spectator
@Override
public long monotonicTime() {
return impl.monotonicTime();
}
}
代码示例来源:origin: Netflix/spectator
/** Create a new instance. */
StatelessMeter(Id id, Clock clock, long ttl) {
this.id = id;
this.clock = clock;
this.ttl = ttl;
lastUpdated = clock.wallTime();
}
代码示例来源:origin: Netflix/spectator
private long getLatency() {
if (startNanos >= 0L && latency < 0L) {
// If latency was not explicitly set but the start time was, then compute the
// time since the start. The field is updated so subsequent calls will return
// a consistent value for the latency.
latency = clock.monotonicTime() - startNanos;
}
return latency;
}
代码示例来源:origin: Netflix/spectator
/**
* Updates the last updated timestamp for the meter to indicate it is active and should
* not be considered expired.
*/
void updateLastModTime() {
lastUpdated = clock.wallTime();
}
代码示例来源:origin: spinnaker/kayenta
long startTime = registry.clock().monotonicTime();
ListTimeSeriesResponse response;
response = list.execute();
} finally {
long endTime = registry.clock().monotonicTime();
Id stackdriverFetchTimerId = registry.createId("stackdriver.fetchTime").withTag("project", projectId);
代码示例来源:origin: apache/servicecomb-java-chassis
public void onInvocationFinish(InvocationFinishEvent event) {
lastUpdated = registry.clock().wallTime();
InvocationStageTrace stageTrace = event.getInvocation().getInvocationStageTrace();
totalTimer.record((long) stageTrace.calcTotalTime());
handlersRequestTimer.record((long) stageTrace.calcHandlersRequestTime());
handlersResponseTimer.record((long) stageTrace.calcHandlersResponseTime());
prepareTimer.record((long) stageTrace.calcInvocationPrepareTime());
}
代码示例来源:origin: org.springframework.metrics/spring-metrics
@Override
public long monotonicTime() {
return impl.monotonicTime();
}
}
代码示例来源:origin: Netflix/spectator
/**
* Return the number of seconds since the last time the counter was incremented.
*/
public double secondsSinceLastUpdate() {
final long now = clock.wallTime();
return (now - lastUpdated.get()) / MILLIS_PER_SECOND;
}
代码示例来源:origin: spinnaker/kayenta
String isoStep = Duration.of(atlasCanaryScope.getStep(), SECONDS) + "";
long start = registry.clock().monotonicTime();
List <AtlasResults> atlasResultsList;
try {
MAX_RETRIES, RETRY_BACKOFF);
} finally {
long end = registry.clock().monotonicTime();
registry.timer("atlas.fetchTime").record(end - start, TimeUnit.NANOSECONDS);
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Return the number of seconds since the last time the counter was incremented.
*/
public double secondsSinceLastUpdate() {
final long now = clock.wallTime();
return (now - lastUpdated.get()) / MILLIS_PER_SECOND;
}
代码示例来源:origin: Netflix/spectator
@Override public long duration() {
long now = clock.monotonicTime();
long sum = 0L;
for (long startTime : tasks.values()) {
sum += now - startTime;
}
return sum;
}
代码示例来源:origin: Netflix/spectator
/** Create a new instance. */
public StepLong(long init, Clock clock, long step) {
this.init = init;
this.clock = clock;
this.step = step;
previous = init;
current = new AtomicLong(init);
lastInitPos = new AtomicLong(clock.wallTime() / step);
}
代码示例来源:origin: com.netflix.spectator/spectator-api
@Override public long duration() {
long now = clock.monotonicTime();
long sum = 0L;
for (long startTime : tasks.values()) {
sum += now - startTime;
}
return sum;
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/** Create a new instance. */
public StepLong(long init, Clock clock, long step) {
this.init = init;
this.clock = clock;
this.step = step;
previous = init;
current = new AtomicLong(init);
lastInitPos = new AtomicLong(clock.wallTime() / step);
}
代码示例来源:origin: Netflix/spectator
@Override public long start() {
long task = nextTask.getAndIncrement();
tasks.put(task, clock.monotonicTime());
return task;
}
内容来源于网络,如有侵权,请联系作者删除!