Skip to content

Commit

Permalink
Adds a comment warning about changing a variable. (#11)
Browse files Browse the repository at this point in the history
* Adds a comment warning about changing a variable.

* Adds a warning note to the assignment of Timestamp.
  • Loading branch information
nkinkade authored Aug 3, 2020
1 parent 41578c8 commit 223d20f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions disco.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ func main() {
metrics.IntervalStart = time.Now()
metrics.Write(start, *fDataDir)
case <-collectTicker.C:
// NOTE: The value of CollectStart is used as the sample Timestamp
// for all metrics from a given collection. The current code relies
// this timestamp always being the same, if this changes, then the
// code in metrics.Collect() will need to be modified.
metrics.CollectStart = time.Now()
metrics.Collect(client, config)
case <-sigterm:
Expand Down
5 changes: 5 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ func (metrics *Metrics) Collect(client snmp.Client, config config.Config) error
metrics.oids[oid].interval.Samples = append(
metrics.oids[oid].interval.Samples,
archive.Sample{
// NOTE: The value of CollectStart is assigned to every metric
// in a given collection, and this fact is taken advantage of in
// metrics.Write(). If we start assigning possibly unique
// timestamps to each sample metric, then the code in Write()
// will need to be modified.
Timestamp: metrics.CollectStart.Unix(),
CollectStart: collectStart.UnixNano(),
CollectEnd: collectEnd.UnixNano(),
Expand Down

0 comments on commit 223d20f

Please sign in to comment.