func NewDBStatsCollector(db DB, opts DBStatsCollectorOpts) prometheus.Collector {
	var fqName func(name string) string
	if opts.DriverName == "" {
		fqName = func(name string) string {
			return "go_db_stats_" + name
		}
	} else {
		fqName = func(name string) string {
			return "go_" + opts.DriverName + "_db_stats_" + name
		}
	}

	return &dbStatsCollector{
		db: db,
		maxOpenConnsDesc: prometheus.NewDesc(
			fqName("max_open_connections"),
			"Maximum number of open connections to the database.",
			nil, nil,
		),
		openConnsDesc: prometheus.NewDesc(
			fqName("open_connections"),
			"The number of established connections both in use and idle.",
			nil, nil,
		),
		inUseDesc: prometheus.NewDesc(
			fqName("in_use"),
			"The number of connections currently in use.",
			nil, nil,
		),
		idleDesc: prometheus.NewDesc(
			fqName("idle"),
			"The number of idle connections.",
			nil, nil,
		),
		waitCountDesc: prometheus.NewDesc(
			fqName("wait_count"),
			"The total number of connections waited for.",
			nil, nil,
		),
		waitDurationDesc: prometheus.NewDesc(
			fqName("wait_duration"),
			"The total time blocked waiting for a new connection.",
			nil, nil,
		),
		maxIdleClosedDesc: prometheus.NewDesc(
			fqName("max_idle_closed"),
			"The total number of connections closed due to SetMaxIdleConns.",
			nil, nil,
		),
		maxIdleTimeClosedDesc: prometheus.NewDesc(
			fqName("max_idle_time_closed"),
			"The total number of connections closed due to SetConnMaxIdleTime.",
			nil, nil,
		),
		maxLifetimeClosedDesc: prometheus.NewDesc(
			fqName("max_lifetime_closed"),
			"The total number of connections closed due to SetConnMaxLifetime.",
			nil, nil,
		),
	}
}
// NewDBStatsCollector returns a collector that exports metrics about the given *sql.DB.
// See https://golang.org/pkg/database/sql/#DBStats for more information on stats.
NewDBStatsCollector returns a collector that exports metrics about the given *sql.DB.
// NewDBStatsCollector returns a collector that exports metrics about the given * sql . DB . // See https : // golang . org / pkg / database / sql / #DBStats for more information on stats .
func NewDBStatsCollector(db DB, opts DBStatsCollectorOpts) prometheus.Collector {
	var fqName func(name string) string
	if opts.DriverName == "" {
		fqName = func(name string) string {
			return "go_db_stats_" + name
		}
	} else {
		fqName = func(name string) string {
			return "go_" + opts.DriverName + "_db_stats_" + name
		}
	}
	return &dbStatsCollector{
		db: db,
		maxOpenConnsDesc: prometheus.NewDesc(
			fqName("max_open_connections"),
			"Maximum number of open connections to the database.",
			nil, nil,
		),
		openConnsDesc: prometheus.NewDesc(
			fqName("open_connections"),
			"The number of established connections both in use and idle.",
			nil, nil,
		),
		inUseDesc: prometheus.NewDesc(
			fqName("in_use"),
			"The number of connections currently in use.",
			nil, nil,
		),
		idleDesc: prometheus.NewDesc(
			fqName("idle"),
			"The number of idle connections.",
			nil, nil,
		),
		waitCountDesc: prometheus.NewDesc(
			fqName("wait_count"),
			"The total number of connections waited for.",
			nil, nil,
		),
		waitDurationDesc: prometheus.NewDesc(
			fqName("wait_duration"),
			"The total time blocked waiting for a new connection.",
			nil, nil,
		),
		maxIdleClosedDesc: prometheus.NewDesc(
			fqName("max_idle_closed"),
			"The total number of connections closed due to SetMaxIdleConns.",
			nil, nil,
		),
		maxIdleTimeClosedDesc: prometheus.NewDesc(
			fqName("max_idle_time_closed"),
			"The total number of connections closed due to SetConnMaxIdleTime.",
			nil, nil,
		),
		maxLifetimeClosedDesc: prometheus.NewDesc(
			fqName("max_lifetime_closed"),
			"The total number of connections closed due to SetConnMaxLifetime.",
			nil, nil,
		),
	}
}
func NewDBStatsCollector ( db DB , opts DBStatsCollectorOpts ) prometheus . Collector { var fqName func ( name string ) string if opts . DriverName == " " { fqName = func ( name string ) string { return " " + name } } else { fqName = func ( name string ) string { return " " + opts . DriverName + " " + name } } return & dbStatsCollector { db : db , maxOpenConnsDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , openConnsDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , inUseDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , idleDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , waitCountDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , waitDurationDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , maxIdleClosedDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , maxIdleTimeClosedDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , maxLifetimeClosedDesc : prometheus . NewDesc ( fqName ( " " ) , " " , nil , nil , ) , } }
NewDBStatsCollector returns a collector that exports metrics about the given *sql.DB.
NewDBStatsCollector returns a collector that exports metrics about the given * sql . DB .