Просмотр исходного кода

Add some more instructive code comments for collector API, and update some names.

Matt Bolt 1 год назад
Родитель
Сommit
0d1eb6a8c2

+ 13 - 0
modules/collector-source/pkg/collector/collector.go

@@ -10,6 +10,10 @@ import (
 // Metric names
 const (
 	ContainerMemoryWorkingSetBytes string = "container_memory_working_set_bytes"
+
+	// So it's easier to track, and so it offers to most compatibility with parsing
+	// the raw metric format, we should use the same metric names as the Prometheus
+	// queries we use to collect the metrics.
 )
 
 // MetricCollectorID is a unique identifier for a specific metric collector instance. We
@@ -21,6 +25,15 @@ type MetricCollectorID string
 const (
 	RAMUsageAverageID MetricCollectorID = "RAMUsageAverage"
 	// etc ...
+
+	// Use ./modules/prometheus-source/pkg/prom/metricsquerier.go as a good
+	// reference for the Queries we require (and therefore, the metrics we need to register).
+
+	// For each new `MetricsCollectorID`, we also need to create a new `New<MetricsCollectorID>MetricsCollector`
+	// function that assembles the metrics collector instance.
+
+	// Lastly, add the `New<MetricsCollectorID>MetricsCollector` function to the `NewOpenCostMetricCollector` function
+	// in ./modules/collector-source/pkg/collector/opencost.go
 )
 
 // MetricsCollector is an interface that defines an implementation capable of managing a collection

+ 1 - 1
modules/collector-source/pkg/collector/metrics.go

@@ -10,7 +10,7 @@ package collector
 // 		)
 // ) by (container, pod, namespace, instance, cluster_id)
 
-func NewRAMUsageAverageMetricInstance() *MetricCollector {
+func NewRAMUsageAverageMetricCollector() *MetricCollector {
 	return NewMetricCollector(
 		RAMUsageAverageID,
 		ContainerMemoryWorkingSetBytes,

+ 1 - 1
modules/collector-source/pkg/collector/opencost.go

@@ -4,7 +4,7 @@ func NewOpenCostMetricCollector() MetricsCollector {
 	memCollector := NewInMemoryMetricsCollector()
 
 	// Register all the metrics
-	memCollector.Register(NewRAMUsageAverageMetricInstance())
+	memCollector.Register(NewRAMUsageAverageMetricCollector())
 	// etc...
 
 	// Use ./modules/prometheus-source/pkg/prom/metricsquerier.go as a good