From 2c08e53be4d7f7d10d203236f4e5b51eddfa75df Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Mon, 28 Feb 2022 09:57:26 +0100 Subject: [PATCH] Additional comments --- collectors/sampleMetric.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/collectors/sampleMetric.go b/collectors/sampleMetric.go index cd3b4cc..47078a6 100644 --- a/collectors/sampleMetric.go +++ b/collectors/sampleMetric.go @@ -22,6 +22,13 @@ type SampleCollector struct { tags map[string]string // default tags } +// Functions to implement MetricCollector interface +// Init(...), Read(...), Close() +// See: metricCollector.go + +// Init initializes the sample collector +// Called once by the collector manager +// All tags, meta data tags and metrics that do not change over the runtime should be set here func (m *SampleCollector) Init(config json.RawMessage) error { var err error = nil // Always set the name early in Init() to use it in cclog.Component* functions @@ -56,12 +63,14 @@ func (m *SampleCollector) Init(config json.RawMessage) error { return err } +// Read collects all metrics belonging to the sample collector +// and sends them through the output channel to the collector manager func (m *SampleCollector) Read(interval time.Duration, output chan lp.CCMetric) { // Create a sample metric timestamp := time.Now() value := 1.0 - // If you want to measure something for a specific amout of time, use interval + // If you want to measure something for a specific amount of time, use interval // start := readState() // time.Sleep(interval) // stop := readState() @@ -75,6 +84,8 @@ func (m *SampleCollector) Read(interval time.Duration, output chan lp.CCMetric) } +// Close metric collector: close network connection, close files, close libraries, ... +// Called once by the collector manager func (m *SampleCollector) Close() { // Unset flag m.init = false