Java Code Examples for com.netflix.spectator.api.Clock#wallTime()

The following examples show how to use com.netflix.spectator.api.Clock#wallTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoubleDistributionSummary.java    From spectator with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new instance.
 */
DoubleDistributionSummary(Clock clock, Id id, long resetFreq) {
  this.clock = clock;
  this.id = id;
  this.resetFreq = resetFreq;
  lastResetTime = new AtomicLong(clock.wallTime());
  lastUpdateTime = new AtomicLong(clock.wallTime());
  count = new AtomicLong(0L);
  totalAmount = new AtomicLong(ZERO);
  totalOfSquares = new AtomicLong(ZERO);
  max = new AtomicLong(ZERO);
  countId = id.withTag(Statistic.count);
  totalAmountId = id.withTag(Statistic.totalAmount);
  totalOfSquaresId = id.withTag(Statistic.totalOfSquares);
  maxId = id.withTag(Statistic.max);
}
 
Example 2
Source File: StatelessMeter.java    From spectator with Apache License 2.0 5 votes vote down vote up
/** Create a new instance. */
StatelessMeter(Id id, Clock clock, long ttl) {
  this.id = id;
  this.clock = clock;
  this.ttl = ttl;
  lastUpdated = clock.wallTime();
}
 
Example 3
Source File: AtlasMeter.java    From spectator with Apache License 2.0 5 votes vote down vote up
/** Create a new instance. */
AtlasMeter(Id id, Clock clock, long ttl) {
  this.id = id;
  this.clock = clock;
  this.ttl = ttl;
  lastUpdated = clock.wallTime();
}
 
Example 4
Source File: AtlasConfig.java    From spectator with Apache License 2.0 5 votes vote down vote up
/**
 * Avoid collecting right on boundaries to minimize transitions on step longs
 * during a collection. By default it will randomly distribute across the middle
 * of the step interval.
 */
default long initialPollingDelay(Clock clock, long stepSize) {
  long now = clock.wallTime();
  long stepBoundary = now / stepSize * stepSize;

  // Buffer by 10% of the step interval on either side
  long offset = stepSize / 10;

  // For larger intervals spread it out, otherwise bias towards the start
  // to ensure there is plenty of time to send without needing to cross over
  // to the next interval. The threshold of 1s was chosen because it is typically
  // big enough to avoid GC troubles where it is common to see pause times in the
  // low 100s of milliseconds.
  if (offset >= 1000L) {
    // Check if the current delay is within the acceptable range
    long delay = now - stepBoundary;
    if (delay < offset) {
      return delay + offset;
    } else {
      return Math.min(delay, stepSize - offset);
    }
  } else {
    long firstTime = stepBoundary + stepSize / 10;
    return firstTime > now
        ? firstTime - now
        : firstTime + stepSize - now;
  }
}
 
Example 5
Source File: CardinalityLimiters.java    From spectator with Apache License 2.0 5 votes vote down vote up
MostFrequentLimiter(int n, Clock clock) {
  this.n = n;
  this.clock = clock;
  this.limiter = first(n);
  this.limiterTimestamp = clock.wallTime();
  this.cutoff = 0L;
  this.updatesWithHighChurn = 0;
}
 
Example 6
Source File: StepDouble.java    From spectator with Apache License 2.0 5 votes vote down vote up
/** Create a new instance. */
public StepDouble(double init, Clock clock, long step) {
  this.init = init;
  this.clock = clock;
  this.step = step;
  previous = init;
  current = new AtomicDouble(init);
  lastInitPos = new AtomicLong(clock.wallTime() / step);
}
 
Example 7
Source File: StepLong.java    From spectator with Apache License 2.0 5 votes vote down vote up
/** 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);
}
 
Example 8
Source File: ServoCounter.java    From spectator with Apache License 2.0 5 votes vote down vote up
/** Create a new instance. */
ServoCounter(Id id, Clock clock, DoubleCounter impl) {
  this.id = id;
  this.clock = clock;
  this.impl = impl;
  this.count = new AtomicDouble(0.0);
  this.lastUpdated = new AtomicLong(clock.wallTime());
}
 
Example 9
Source File: ServoGauge.java    From spectator with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new monitor that returns {@code value}.
 */
ServoGauge(Id id, Clock clock, MonitorConfig config) {
  super(config.withAdditionalTag(DataSourceType.GAUGE));
  this.id = id;
  this.clock = clock;
  this.value = new AtomicDouble(Double.NaN);
  this.lastUpdated = new AtomicLong(clock.wallTime());
}
 
Example 10
Source File: ServoMaxGauge.java    From spectator with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new monitor that returns {@code value}.
 */
ServoMaxGauge(Id id, Clock clock, MonitorConfig config) {
  super(config.withAdditionalTag(DataSourceType.GAUGE));
  this.id = id;
  this.clock = clock;
  this.impl = new MaxGauge(config);
  this.lastUpdated = new AtomicLong(clock.wallTime());
}
 
Example 11
Source File: Scheduler.java    From spectator with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new instance.
 *
 * @param clock
 *     Clock for computing the next execution time for the task.
 * @param options
 *     Options for how to repeat the execution.
 * @param task
 *     User specified task to execute.
 */
DelayedTask(Clock clock, Options options, Runnable task) {
  this.clock = clock;
  this.options = options;
  this.task = task;
  this.initialExecutionTime = clock.wallTime() + options.initialDelay;
  this.nextExecutionTime = initialExecutionTime;
}