scrape/target.go
func (t *Target) offset(interval time.Duration, jitterSeed uint64) time.Duration {
	now := time.Now().UnixNano()

	// Base is a pinned to absolute time, no matter how often offset is called.
	var (
		base   = int64(interval) - now%int64(interval)
		offset = (t.hash() ^ jitterSeed) % uint64(interval)
		next   = base + int64(offset)
	)

	if next > int64(interval) {
		next -= int64(interval)
	}
	return time.Duration(next)
}
func (t *Target) offset(interval time.Duration, jitterSeed uint64) time.Duration {
	now := time.Now().UnixNano()

	// Base is a pinned to absolute time, no matter how often offset is called.
	var (
		base   = int64(interval) - now%int64(interval)
		offset = (t.hash() ^ jitterSeed) % uint64(interval)
		next   = base + int64(offset)
	)

	if next > int64(interval) {
		next -= int64(interval)
	}
	return time.Duration(next)
}
func ( t * Target ) offset ( interval time . Duration , jitterSeed uint64 ) time . Duration { now := time . Now ( ) . UnixNano ( ) // Base is a pinned to absolute time, no matter how often offset is called. var ( base = int64 ( interval ) - now % int64 ( interval ) offset = ( t . hash ( ) ^ jitterSeed ) % uint64 ( interval ) next = base + int64 ( offset ) ) if next > int64 ( interval ) { next -= int64 ( interval ) } return time . Duration ( next ) }
// offset returns the time until the next scrape cycle for the target.
// It includes the global server jitterSeed for scrapes from multiple Prometheus to try to be at different times.
offset returns the time until the next scrape cycle for the target . It includes the global server jitterSeed for scrapes from multiple Prometheus to try to be at different times .