Java Code Examples for io.micrometer.core.instrument.Clock#wallTime()

The following examples show how to use io.micrometer.core.instrument.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: AbstractTimeWindowHistogram.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
AbstractTimeWindowHistogram(Clock clock, DistributionStatisticConfig distributionStatisticConfig, Class<T> bucketType,
                            boolean supportsAggregablePercentiles) {
    this.clock = clock;
    this.distributionStatisticConfig = validateDistributionConfig(distributionStatisticConfig);
    this.supportsAggregablePercentiles = supportsAggregablePercentiles;

    final int ageBuckets = distributionStatisticConfig.getBufferLength();
    if (ageBuckets <= 0) {
        rejectHistogramConfig("bufferLength (" + ageBuckets + ") must be greater than 0.");
    }

    ringBuffer = (T[]) Array.newInstance(bucketType, ageBuckets);

    durationBetweenRotatesMillis = distributionStatisticConfig.getExpiry().toMillis() / ageBuckets;
    if (durationBetweenRotatesMillis <= 0) {
        rejectHistogramConfig("expiry (" + distributionStatisticConfig.getExpiry().toMillis() +
                "ms) / bufferLength (" + ageBuckets + ") must be greater than 0.");
    }

    currentBucket = 0;
    lastRotateTimestampMillis = clock.wallTime();
}
 
Example 2
Source File: TimeWindowMax.java    From micrometer with Apache License 2.0 5 votes vote down vote up
public TimeWindowMax(Clock clock, long rotateFrequencyMillis, int bufferLength) {
    this.clock = clock;
    this.durationBetweenRotatesMillis = rotateFrequencyMillis;
    this.lastRotateTimestampMillis = clock.wallTime();
    this.currentBucket = 0;

    this.ringBuffer = new AtomicLong[bufferLength];
    for (int i = 0; i < bufferLength; i++) {
        this.ringBuffer[i] = new AtomicLong();
    }
}
 
Example 3
Source File: StepTuple2.java    From micrometer with Apache License 2.0 5 votes vote down vote up
public StepTuple2(Clock clock, long stepMillis,
                 T1 t1NoValue,
                 T2 t2NoValue,
                 Supplier<T1> t1Supplier,
                 Supplier<T2> t2Supplier) {
    this.clock = clock;
    this.stepMillis = stepMillis;
    this.t1NoValue = t1NoValue;
    this.t2NoValue = t2NoValue;
    this.t1Supplier = t1Supplier;
    this.t2Supplier = t2Supplier;
    this.t1Previous = t1NoValue;
    this.t2Previous = t2NoValue;
    lastInitPos = new AtomicLong(clock.wallTime() / stepMillis);
}
 
Example 4
Source File: StepValue.java    From micrometer with Apache License 2.0 4 votes vote down vote up
public StepValue(final Clock clock, final long stepMillis) {
    this.clock = clock;
    this.stepMillis = stepMillis;
    lastInitPos = new AtomicLong(clock.wallTime() / stepMillis);
}