// NewCollector gets you the new Collector
542024
func NewCollector(logger log.Logger, scheduler *sfxclient.Scheduler) *Collector {
	return &Collector{
		scheduler: scheduler,
		logger:    logger,
		jsonfunc:  json.Marshal,
	}
}
1254001
func (m *cacheMetrics) PrometheusCollectors() []prometheus.Collector {
	return []prometheus.Collector{
		m.Size,
		m.Gets,
		m.Puts,
		m.Deletes,
		m.Evictions,
	}
}
657736
func NewStatCollector() (Collector, error) {
	fs, err := procfs.NewFS(*procPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open procfs: %v", err)
	}
	return &statCollector{
		fs: fs,
		intr: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "", "intr_total"),
			"Total number of interrupts serviced.",
			nil, nil,
		),
		ctxt: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "", "context_switches_total"),
			"Total number of context switches.",
			nil, nil,
		),
		forks: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "", "forks_total"),
			"Total number of forks.",
			nil, nil,
		),
		btime: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "", "boot_time_seconds"),
			"Node boot time, in unixtime.",
			nil, nil,
		),
		procsRunning: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "", "procs_running"),
			"Number of processes in runnable state.",
			nil, nil,
		),
		procsBlocked: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, "", "procs_blocked"),
			"Number of processes blocked waiting for I/O to complete.",
			nil, nil,
		),
	}, nil
}
445567
func NewBcacheCollector() (Collector, error) {
	fs, err := sysfs.NewFS(*sysPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open sysfs: %v", err)
	}

	return &bcacheCollector{
		fs: fs,
	}, nil
}
1014970
func NewCollector(store *store.MemoryStore) *Collector {
	return &Collector{
		store:    store,
		stopChan: make(chan struct{}),
		doneChan: make(chan struct{}),
	}
}
103603
func NewInfiniBandCollector() (Collector, error) {
	var i infinibandCollector

	// Filenames of all InfiniBand counter metrics including a detailed description.
	i.counters = map[string]infinibandMetric{
		"link_downed_total":                        {"link_downed", "Number of times the link failed to recover from an error state and went down"},
		"link_error_recovery_total":                {"link_error_recovery", "Number of times the link successfully recovered from an error state"},
		"multicast_packets_received_total":         {"multicast_rcv_packets", "Number of multicast packets received (including errors)"},
		"multicast_packets_transmitted_total":      {"multicast_xmit_packets", "Number of multicast packets transmitted (including errors)"},
		"port_constraint_errors_received_total":    {"port_rcv_constraint_errors", "Number of packets received on the switch physical port that are discarded"},
		"port_constraint_errors_transmitted_total": {"port_xmit_constraint_errors", "Number of packets not transmitted from the switch physical port"},
		"port_data_received_bytes_total":           {"port_rcv_data", "Number of data octets received on all links"},
		"port_data_transmitted_bytes_total":        {"port_xmit_data", "Number of data octets transmitted on all links"},
		"port_discards_received_total":             {"port_rcv_discards", "Number of inbound packets discarded by the port because the port is down or congested"},
		"port_discards_transmitted_total":          {"port_xmit_discards", "Number of outbound packets discarded by the port because the port is down or congested"},
		"port_errors_received_total":               {"port_rcv_errors", "Number of packets containing an error that were received on this port"},
		"port_packets_received_total":              {"port_rcv_packets", "Number of packets received on all VLs by this port (including errors)"},
		"port_packets_transmitted_total":           {"port_xmit_packets", "Number of packets transmitted on all VLs from this port (including errors)"},
		"port_transmit_wait_total":                 {"port_xmit_wait", "Number of ticks during which the port had data to transmit but no data was sent during the entire tick"},
		"unicast_packets_received_total":           {"unicast_rcv_packets", "Number of unicast packets received (including errors)"},
		"unicast_packets_transmitted_total":        {"unicast_xmit_packets", "Number of unicast packets transmitted (including errors)"},
	}

	// Deprecated counters for some older versions of InfiniBand drivers.
	i.legacyCounters = map[string]infinibandMetric{
		"legacy_multicast_packets_received_total":    {"port_multicast_rcv_packets", "Number of multicast packets received"},
		"legacy_multicast_packets_transmitted_total": {"port_multicast_xmit_packets", "Number of multicast packets transmitted"},
		"legacy_data_received_bytes_total":           {"port_rcv_data_64", "Number of data octets received on all links"},
		"legacy_packets_received_total":              {"port_rcv_packets_64", "Number of data packets received on all links"},
		"legacy_unicast_packets_received_total":      {"port_unicast_rcv_packets", "Number of unicast packets received"},
		"legacy_unicast_packets_transmitted_total":   {"port_unicast_xmit_packets", "Number of unicast packets transmitted"},
		"legacy_data_transmitted_bytes_total":        {"port_xmit_data_64", "Number of data octets transmitted on all links"},
		"legacy_packets_transmitted_total":           {"port_xmit_packets_64", "Number of data packets received on all links"},
	}

	subsystem := "infiniband"
	i.metricDescs = make(map[string]*prometheus.Desc)

	for metricName, infinibandMetric := range i.counters {
		i.metricDescs[metricName] = prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, metricName),
			infinibandMetric.Help,
			[]string{"device", "port"},
			nil,
		)
	}

	for metricName, infinibandMetric := range i.legacyCounters {
		i.metricDescs[metricName] = prometheus.NewDesc(
			prometheus.BuildFQName(namespace, subsystem, metricName),
			infinibandMetric.Help,
			[]string{"device", "port"},
			nil,
		)
	}

	return &i, nil
}
412820
func NewvmStatCollector() (Collector, error) {
	pattern := regexp.MustCompile(*vmStatFields)
	return &vmStatCollector{
		fieldPattern: pattern,
	}, nil
}
775952
func (m *seriesFileMetrics) PrometheusCollectors() []prometheus.Collector {
	return []prometheus.Collector{
		m.SeriesCreated,
		m.Series,
		m.DiskSize,
		m.Segments,
		m.CompactionsActive,
		m.CompactionDuration,
		m.Compactions,
	}
}
947812
func NewCPUCollector() (Collector, error) {
	fs, err := procfs.NewFS(*procPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open procfs: %v", err)
	}
	return &cpuCollector{
		fs:  fs,
		cpu: nodeCPUSecondsDesc,
		cpuGuest: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "guest_seconds_total"),
			"Seconds the cpus spent in guests (VMs) for each mode.",
			[]string{"cpu", "mode"}, nil,
		),
		cpuCoreThrottle: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "core_throttles_total"),
			"Number of times this cpu core has been throttled.",
			[]string{"package", "core"}, nil,
		),
		cpuPackageThrottle: prometheus.NewDesc(
			prometheus.BuildFQName(namespace, cpuCollectorSubsystem, "package_throttles_total"),
			"Number of times this cpu package has been throttled.",
			[]string{"package"}, nil,
		),
	}, nil
}
935892
func NewInterruptsCollector() (Collector, error) {
	return &interruptsCollector{
		desc: typedDesc{prometheus.NewDesc(
			namespace+"_interrupts_total",
			"Interrupt details.",
			interruptLabelNames, nil,
		), prometheus.CounterValue},
	}, nil
}
7001
func NewNetClassCollector() (Collector, error) {
	fs, err := sysfs.NewFS(*sysPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open sysfs: %v", err)
	}
	pattern := regexp.MustCompile(*netclassIgnoredDevices)
	return &netClassCollector{
		fs:                    fs,
		subsystem:             "network",
		ignoredDevicesPattern: pattern,
		metricDescs:           map[string]*prometheus.Desc{},
	}, nil
}
236362
func (rm *retentionMetrics) PrometheusCollectors() []prometheus.Collector {
	return []prometheus.Collector{
		rm.Checks,
		rm.CheckDuration,
		rm.Unprocessable,
		rm.Series,
	}
}
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
}
507726
func (f File) New() cue.Collector {
	if f.Path == "" {
		log.Warn("File.New called to created a collector, but Path param is empty.  Returning nil collector.")
		return nil
	}
	if f.Formatter == nil {
		f.Formatter = format.HumanReadable
	}
	if f.Flags == 0 {
		f.Flags = os.O_CREATE | os.O_WRONLY | os.O_APPEND
	}
	if f.Perms == 0 {
		f.Perms = 0600
	}

	fc := &fileCollector{File: f}
	fc.watchSignal()
	fc.watchRemoval()
	return fc
}
1113019
func (w *workManager) AddCollectWorker() {
	nw := newWorker(w.collectchan)
	go nw.start()
	w.collectWkrs = append(w.collectWkrs, nw)
	w.collectWkrSize++
}
651984
func NewInfluxCollector(procID platform.IDGenerator, build platform.BuildInfo) prometheus.Collector {
	id := procID.ID().String()

	return &influxCollector{
		influxInfoDesc: prometheus.NewDesc(
			"influxdb_info",
			"Information about the influxdb environment.",
			nil, prometheus.Labels{
				"version":    build.Version,
				"commit":     build.Commit,
				"build_date": build.Date,
				"os":         runtime.GOOS,
				"arch":       runtime.GOARCH,
				"cpus":       strconv.Itoa(runtime.NumCPU()),
			},
		),
		influxUptimeDesc: prometheus.NewDesc(
			"influxdb_uptime_seconds",
			"influxdb process uptime in seconds",
			nil, prometheus.Labels{
				"id": id,
			},
		),
		start: time.Now(),
	}
}
253220
func (h Honeybadger) New() cue.Collector {
	if h.Key == "" {
		log.Warn("Honeybadger.New called to created a collector, but Key param is empty.  Returning nil collector.")
		return nil
	}
	return &honeybadgerCollector{
		Honeybadger: h,
		http:        collector.HTTP{RequestFormatter: h.formatRequest}.New(),
	}
}