// NewTimexCollector returns a new Collector exposing adjtime(3) stats.
187382
func NewTimexCollector() (Collector, error) {
	const subsystem = "timex"

	return &timexCollector{
		offset: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "offset_seconds"),
			"Time offset in between local system and reference clock.",
			nil, nil,
		), prometheus.GaugeValue},
		freq: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "frequency_adjustment_ratio"),
			"Local clock frequency adjustment.",
			nil, nil,
		), prometheus.GaugeValue},
		maxerror: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "maxerror_seconds"),
			"Maximum error in seconds.",
			nil, nil,
		), prometheus.GaugeValue},
		esterror: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "estimated_error_seconds"),
			"Estimated error in seconds.",
			nil, nil,
		), prometheus.GaugeValue},
		status: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "status"),
			"Value of the status array bits.",
			nil, nil,
		), prometheus.GaugeValue},
		constant: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "loop_time_constant"),
			"Phase-locked loop time constant.",
			nil, nil,
		), prometheus.GaugeValue},
		tick: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "tick_seconds"),
			"Seconds between clock ticks.",
			nil, nil,
		), prometheus.GaugeValue},
		ppsfreq: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "pps_frequency_hertz"),
			"Pulse per second frequency.",
			nil, nil,
		), prometheus.GaugeValue},
		jitter: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "pps_jitter_seconds"),
			"Pulse per second jitter.",
			nil, nil,
		), prometheus.GaugeValue},
		shift: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "pps_shift_seconds"),
			"Pulse per second interval duration.",
			nil, nil,
		), prometheus.GaugeValue},
		stabil: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "pps_stability_hertz"),
			"Pulse per second stability, average of recent frequency changes.",
			nil, nil,
		), prometheus.GaugeValue},
		jitcnt: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "pps_jitter_total"),
			"Pulse per second count of jitter limit exceeded events.",
			nil, nil,
		), prometheus.CounterValue},
		calcnt: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "pps_calibration_total"),
			"Pulse per second count of calibration intervals.",
			nil, nil,
		), prometheus.CounterValue},
		errcnt: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "pps_error_total"),
			"Pulse per second count of calibration errors.",
			nil, nil,
		), prometheus.CounterValue},
		stbcnt: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "pps_stability_exceeded_total"),
			"Pulse per second count of stability limit exceeded events.",
			nil, nil,
		), prometheus.CounterValue},
		tai: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "tai_offset_seconds"),
			"International Atomic Time (TAI) offset.",
			nil, nil,
		), prometheus.GaugeValue},
		syncStatus: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, "sync_status"),
			"Is clock synchronized to a reliable server (1 = yes, 0 = no).",
			nil, nil,
		), prometheus.GaugeValue},
	}, nil
}
845310
func (m *blockMetrics) PrometheusCollectors() []prometheus.Collector {
	var metrics []prometheus.Collector
	metrics = append(metrics, m.compactionMetrics.PrometheusCollectors()...)
	metrics = append(metrics, m.fileMetrics.PrometheusCollectors()...)
	metrics = append(metrics, m.cacheMetrics.PrometheusCollectors()...)
	return metrics
}
262802
func NewStatCollector() (Collector, error) {
	return &statCollector{
		cpu: typedDesc{nodeCPUSecondsDesc, prometheus.CounterValue},
		temp: typedDesc{prometheus.NewDesc(
			prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "temperature_celsius"),
			"CPU temperature",
			[]string{"cpu"}, nil,
		), prometheus.GaugeValue},
	}, nil
}
542024
func NewCollector(logger log.Logger, scheduler *sfxclient.Scheduler) *Collector {
	return &Collector{
		scheduler: scheduler,
		logger:    logger,
		jsonfunc:  json.Marshal,
	}
}
359831
func NewMemoryCollector() (Collector, error) {
	tmp32, err := unix.SysctlUint32("vm.stats.vm.v_page_size")
	if err != nil {
		return nil, fmt.Errorf("sysctl(vm.stats.vm.v_page_size) failed: %s", err)
	}
	size := float64(tmp32)

	mibSwapTotal := "vm.swap_total"
	/* swap_total is FreeBSD specific. Fall back to Dfly specific mib if not present. */
	_, err = unix.SysctlUint32(mibSwapTotal)
	if err != nil {
		mibSwapTotal = "vm.swap_size"
	}

	fromPage := func(v float64) float64 {
		return v * size
	}

	return &memoryCollector{
		pageSize: uint64(tmp32),
		sysctls: []bsdSysctl{
			// Descriptions via: https://wiki.freebsd.org/Memory
			{
				name:        "active_bytes",
				description: "Recently used by userland",
				mib:         "vm.stats.vm.v_active_count",
				conversion:  fromPage,
			},
			{
				name:        "inactive_bytes",
				description: "Not recently used by userland",
				mib:         "vm.stats.vm.v_inactive_count",
				conversion:  fromPage,
			},
			{
				name:        "wired_bytes",
				description: "Locked in memory by kernel, mlock, etc",
				mib:         "vm.stats.vm.v_wire_count",
				conversion:  fromPage,
			},
			{
				name:        "cache_bytes",
				description: "Almost free, backed by swap or files, available for re-allocation",
				mib:         "vm.stats.vm.v_cache_count",
				conversion:  fromPage,
			},
			{
				name:        "buffer_bytes",
				description: "Disk IO Cache entries for non ZFS filesystems, only usable by kernel",
				mib:         "vfs.bufspace",
				dataType:    bsdSysctlTypeCLong,
			},
			{
				name:        "free_bytes",
				description: "Unallocated, available for allocation",
				mib:         "vm.stats.vm.v_free_count",
				conversion:  fromPage,
			},
			{
				name:        "size_bytes",
				description: "Total physical memory size",
				mib:         "vm.stats.vm.v_page_count",
				conversion:  fromPage,
			},
			{
				name:        "swap_size_bytes",
				description: "Total swap memory size",
				mib:         mibSwapTotal,
				dataType:    bsdSysctlTypeUint64,
			},
			// Descriptions via: top(1)
			{
				name:        "swap_in_bytes_total",
				description: "Bytes paged in from swap devices",
				mib:         "vm.stats.vm.v_swappgsin",
				valueType:   prometheus.CounterValue,
				conversion:  fromPage,
			},
			{
				name:        "swap_out_bytes_total",
				description: "Bytes paged out to swap devices",
				mib:         "vm.stats.vm.v_swappgsout",
				valueType:   prometheus.CounterValue,
				conversion:  fromPage,
			},
		},
	}, nil
}
164945
func PrometheusCollectors() []prometheus.Collector {
	mmu.RLock()
	defer mmu.RUnlock()

	var collectors []prometheus.Collector
	if cms != nil {
		collectors = append(collectors, cms.PrometheusCollectors()...)
	}
	if pms != nil {
		collectors = append(collectors, pms.PrometheusCollectors()...)
	}
	return collectors
}
862367
func (RealTime) NewTimer(d time.Duration) Timer {
	return &builtinTimer{
		timer: time.NewTimer(d),
	}
}
828286
func NewEdacCollector() (Collector, error) {
	return &edacCollector{
		ceCount: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, edacSubsystem, "correctable_errors_total"),
			"Total correctable memory errors.",
			[]string{"controller"}, nil,
		),
		ueCount: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, edacSubsystem, "uncorrectable_errors_total"),
			"Total uncorrectable memory errors.",
			[]string{"controller"}, nil,
		),
		csRowCECount: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, edacSubsystem, "csrow_correctable_errors_total"),
			"Total correctable memory errors for this csrow.",
			[]string{"controller", "csrow"}, nil,
		),
		csRowUECount: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, edacSubsystem, "csrow_uncorrectable_errors_total"),
			"Total uncorrectable memory errors for this csrow.",
			[]string{"controller", "csrow"}, nil,
		),
	}, nil
}
9289
func (m *compactionMetrics) PrometheusCollectors() []prometheus.Collector {
	return []prometheus.Collector{
		m.Compactions,
		m.CompactionsActive,
		m.CompactionDuration,
		m.CompactionQueue,
	}
}
33952
func PrometheusCollectors() []prometheus.Collector {
	mmu.RLock()
	defer mmu.RUnlock()

	var collectors []prometheus.Collector
	if bms != nil {
		collectors = append(collectors, bms.compactionMetrics.PrometheusCollectors()...)
		collectors = append(collectors, bms.fileMetrics.PrometheusCollectors()...)
		collectors = append(collectors, bms.cacheMetrics.PrometheusCollectors()...)
	}
	return collectors
}
1363488
func (m *fileMetrics) PrometheusCollectors() []prometheus.Collector {
	return []prometheus.Collector{
		m.DiskSize,
		m.Files,
	}
}
1235565
func (h *Handler) PrometheusCollectors() []prometheus.Collector {
	return []prometheus.Collector{
		h.requests,
		h.requestDur,
	}
}
619618
func (f *FakeClock) NewTimer(d time.Duration) Timer {
	f.lock.Lock()
	defer f.lock.Unlock()
	stopTime := f.time.Add(d)
	ch := make(chan time.Time, 1) // Don't block!
	timer := &fakeTimer{
		fakeClock: f,
		waiter: fakeClockWaiter{
			targetTime: stopTime,
			destChan:   ch,
		},
	}
	f.waiters = append(f.waiters, timer.waiter)
	return timer
}
947238
func NewNetDevCollector() (Collector, error) {
	pattern := regexp.MustCompile(*netdevIgnoredDevices)
	return &netDevCollector{
		subsystem:             "network",
		ignoredDevicesPattern: pattern,
		metricDescs:           map[string]*prometheus.Desc{},
	}, nil
}
41650
func (d *DefaultMetricCollector) TotalDuration() *rolling.Timing {
	d.mutex.RLock()
	defer d.mutex.RUnlock()
	return d.totalDuration
}
1011517
func (m *walMetrics) PrometheusCollectors() []prometheus.Collector {
	return []prometheus.Collector{
		m.OldSegmentBytes,
		m.CurrentSegmentBytes,
		m.Segments,
		m.Writes,
	}
}
846431
func NewNetStatCollector() (Collector, error) {
	pattern := regexp.MustCompile(*netStatFields)
	return &netStatCollector{
		fieldPattern: pattern,
	}, nil
}