Skip to content

Commit 0ed7fd7

Browse files
committed
add comments
1 parent d17fb42 commit 0ed7fd7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

rds.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import (
99
"github.com/prometheus/common/log"
1010
)
1111

12+
// DBMaxConnections is a hardcoded map of instance types and DB Parameter Group names
13+
// This is a dump workaround created because by default the DB Parameter Group `max_connections` is a function
14+
// that is hard to parse and process in code and it contains a variable whose value is unknown to us (DBInstanceClassMemory)
15+
// AWS has no means to return the actual `max_connections` value.
1216
var DBMaxConnections = map[string]map[string]int64{
1317
"db.t2.small": map[string]int64{
1418
"default.mysql5.7": 150,
@@ -21,6 +25,7 @@ var DBMaxConnections = map[string]map[string]int64{
2125
},
2226
}
2327

28+
// RDSExporter defines an instance of the RDS Exporter
2429
type RDSExporter struct {
2530
sess *session.Session
2631
AllocatedStorage *prometheus.Desc
@@ -35,6 +40,7 @@ type RDSExporter struct {
3540
mutex *sync.Mutex
3641
}
3742

43+
// NewRDSExporter creates a new RDSExporter instance
3844
func NewRDSExporter(sess *session.Session) *RDSExporter {
3945
log.Info("[RDS] Initializing RDS exporter")
4046
return &RDSExporter{
@@ -79,12 +85,14 @@ func NewRDSExporter(sess *session.Session) *RDSExporter {
7985
}
8086
}
8187

88+
// Describe is used by the Prometheus client to return a description of the metrics
8289
func (e *RDSExporter) Describe(ch chan<- *prometheus.Desc) {
8390
ch <- e.AllocatedStorage
8491
ch <- e.DBInstanceStatus
8592
ch <- e.EngineVersion
8693
}
8794

95+
// Collect is used by the Prometheus client to collect and return the metrics values
8896
func (e *RDSExporter) Collect(ch chan<- prometheus.Metric) {
8997
svc := rds.New(e.sess)
9098
input := &rds.DescribeDBInstancesInput{}

0 commit comments

Comments
 (0)