private Double pollAndUpdate()

in core/src/main/java/com/spotify/metrics/core/DerivedLongGauge.java [110:133]


    private Double pollAndUpdate(final long currentTime) {
        long timeDiff = currentTime - lastUpdate;

        if (timeDiff <= 0) {
            return null;
        }

        final Long currentValue = this.getNext();
        final Long lastValue = this.lastValue;
        this.lastValue = currentValue;

        if (lastValue == null || currentValue == null) {
            return null;
        }

        final double valueDiff = (double) (currentValue - lastValue);

        // ignore negative values.
        if (valueDiff < 0) {
            return null;
        }

        return (valueDiff / timeDiff) * 1000;
    }