You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package collector
import "github.com/prometheus/client_golang/prometheus"
// Scraper 所有指标收集需要满足2个方法 name返回指标名字来用于用户开关指标的 可以理解为所有指标都必须满足这个约定
//
//等同于我们一个接口切片,将结构体赋值给接口 但是结构体需要满足接口的方法, 然后range 并调用接口的Scrape 来采集指标
//
//go的接口继承类似于鸭子 接口定义了鸭子长什么样子也就是需要实现的方法,那么我们实现了这些方法的结构体就是一只鸭子 然后map中的k是一个接口 我们赋予的是一个结构体 结构体实现了接口的方法, 那么我们就可以吧结构体赋值给接口
type Scraper interface {
// Name of the Scraper. Should be unique.
Name ( ) string
// Help describes the role of the Scraper.
// Example: "Collect from SHOW ENGINE INNODB STATUS"
//Help() string
// Scrape collects data from client and sends it over channel as prometheus metric.
Scrape ( ch chan <- prometheus . Metric ) error
}