mirror of
https://github.com/prometheus/prometheus.git
synced 2026-04-23 15:20:11 -04:00
scrape: address comments on PR
Signed-off-by: Ridwan Sharif <ridwanmsharif@google.com>
This commit is contained in:
parent
8e8cd480cb
commit
101ae73380
3 changed files with 5 additions and 11 deletions
|
|
@ -149,9 +149,8 @@ type Options struct {
|
|||
// because of an early startup scrape.
|
||||
InitialScrapeOffset time.Duration
|
||||
|
||||
// private options for testability.
|
||||
// private option for testability.
|
||||
skipJitterOffsetting bool
|
||||
offsetSeed uint64
|
||||
}
|
||||
|
||||
// Manager maintains a set of scrape pools and manages start/stop cycles
|
||||
|
|
@ -270,11 +269,6 @@ func (m *Manager) reload() {
|
|||
|
||||
// setOffsetSeed calculates a global offsetSeed per server relying on extra label set.
|
||||
func (m *Manager) setOffsetSeed(labels labels.Labels) error {
|
||||
if m.opts.offsetSeed != 0 {
|
||||
m.offsetSeed = m.opts.offsetSeed
|
||||
return nil
|
||||
}
|
||||
|
||||
h := fnv.New64a()
|
||||
hostname, err := osutil.GetFQDN()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -1253,9 +1253,8 @@ func (sl *scrapeLoop) getScrapeOffset() time.Duration {
|
|||
|
||||
func (sl *scrapeLoop) run(errc chan<- error) {
|
||||
var (
|
||||
last time.Time
|
||||
alignedScrapeTime = time.Now().Round(0)
|
||||
ticker = time.NewTicker(sl.interval)
|
||||
last time.Time
|
||||
ticker = time.NewTicker(sl.interval)
|
||||
)
|
||||
defer func() {
|
||||
if sl.scrapeOnShutdown {
|
||||
|
|
@ -1284,6 +1283,7 @@ func (sl *scrapeLoop) run(errc chan<- error) {
|
|||
|
||||
// Reset the ticker so target scrape times are aligned to the offset+intervals.
|
||||
ticker.Reset(sl.interval)
|
||||
alignedScrapeTime := time.Now().Round(0)
|
||||
|
||||
for {
|
||||
select {
|
||||
|
|
|
|||
|
|
@ -6823,7 +6823,6 @@ func TestScrapeOffsetDistribution(t *testing.T) {
|
|||
|
||||
app := teststorage.NewAppendable()
|
||||
opts := &Options{
|
||||
offsetSeed: 1,
|
||||
HTTPClientOptions: []config_util.HTTPClientOption{
|
||||
config_util.WithDialContextFunc(func(ctx context.Context, _, _ string) (net.Conn, error) {
|
||||
srvConn, cliConn := net.Pipe()
|
||||
|
|
@ -6839,6 +6838,7 @@ func TestScrapeOffsetDistribution(t *testing.T) {
|
|||
},
|
||||
}
|
||||
scrapeManager, err := NewManager(opts, promslog.NewNopLogger(), nil, app, nil, prometheus.NewRegistry())
|
||||
scrapeManager.offsetSeed = 1 // Set a fixed offset seed for deterministic testing.
|
||||
require.NoError(t, err)
|
||||
|
||||
var targets []model.LabelSet
|
||||
|
|
|
|||
Loading…
Reference in a new issue