MCPcopy
hub / github.com/prometheus/prometheus / validateOptions

Function validateOptions

tsdb/agent/db.go:377–410  ·  view source on GitHub ↗
(opts *Options)

Source from the content-addressed store, hash-verified

375}
376
377func validateOptions(opts *Options) *Options {
378 if opts == nil {
379 opts = DefaultOptions()
380 }
381 if opts.WALSegmentSize <= 0 {
382 opts.WALSegmentSize = wlog.DefaultSegmentSize
383 }
384
385 if opts.WALCompression == "" {
386 opts.WALCompression = compression.None
387 }
388
389 // Revert StripeSize to DefaultStripeSize if StripeSize is either 0 or not a power of 2.
390 if opts.StripeSize <= 0 || ((opts.StripeSize & (opts.StripeSize - 1)) != 0) {
391 opts.StripeSize = tsdb.DefaultStripeSize
392 }
393 if opts.TruncateFrequency <= 0 {
394 opts.TruncateFrequency = DefaultTruncateFrequency
395 }
396 if opts.MinWALTime <= 0 {
397 opts.MinWALTime = DefaultMinWALTime
398 }
399 if opts.MaxWALTime <= 0 {
400 opts.MaxWALTime = DefaultMaxWALTime
401 }
402 if opts.MinWALTime > opts.MaxWALTime {
403 opts.MaxWALTime = opts.MinWALTime
404 }
405
406 if t := int64(opts.TruncateFrequency / time.Millisecond); opts.MaxWALTime < t {
407 opts.MaxWALTime = t
408 }
409 return opts
410}
411
412func (db *DB) replayWAL() error {
413 db.logger.Info("replaying WAL, this may take a while", "dir", db.wal.Dir())

Callers 2

OpenFunction · 0.85
Test_validateOptionsFunction · 0.85

Calls 1

DefaultOptionsFunction · 0.70

Tested by 1

Test_validateOptionsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…