Skip to content

Commit

Permalink
[#1375] Extend the comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fivitti committed Jun 25, 2024
1 parent 18b4f4c commit a3c6350
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/server/metrics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ type prometheusCollector struct {
subnetPdUtilizationDescriptor *prometheus.Desc
sharedNetworkAddressUtilizationDescriptor *prometheus.Desc
sharedNetworkPdUtilizationDescriptor *prometheus.Desc
// The statistics are stored as a map in the dbmodel.SharedNetwork
// structure. So, it is possible to handle all of them in the same way and
// convert them to the Prometheus metrics using for-loop. The collector
// must store them in an iterable structure, such as a map, to achieve
// this.
//
// The metrics must be iterated in the strict order.
// The default map's iteration order in Golang is indeterministic. It isn't
// specified if the order is preserved for subsequent iterations. The
// collector iterates the metrics twice: in the Desc and the Collect
// methods. The iteration order must be the same. Otherwise, the samples
// will be assigned to the wrong metrics. Therefore, the OrderedMap is used
// here.
sharedNetworkStatisticDescriptors *storkutil.OrderedMap[dbmodel.SubnetStatsName, *prometheus.Desc]
}

Expand Down

0 comments on commit a3c6350

Please sign in to comment.