mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-14 08:57:40 +00:00
make collector a singleton
This commit is contained in:
parent
9722ad7a41
commit
a72e25accf
2 changed files with 8 additions and 1 deletions
|
@ -29,6 +29,13 @@ type collector struct {
|
||||||
bucketsPerRole *prometheus.GaugeVec
|
bucketsPerRole *prometheus.GaugeVec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var metricsInstance metricsCollector
|
||||||
|
|
||||||
|
func init() { metricsInstance = newS3MetricsCollector() }
|
||||||
|
|
||||||
|
// getMetricsCollector returns the singleton metrics collector instance..
|
||||||
|
func getMetricsCollector() metricsCollector { return metricsInstance }
|
||||||
|
|
||||||
func newS3MetricsCollector() metricsCollector {
|
func newS3MetricsCollector() metricsCollector {
|
||||||
return &collector{
|
return &collector{
|
||||||
objectsScanned: promauto.NewCounterVec(prometheus.CounterOpts{
|
objectsScanned: promauto.NewCounterVec(prometheus.CounterOpts{
|
||||||
|
|
|
@ -99,7 +99,7 @@ func (s *Source) Init(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
s.metricsCollector = newS3MetricsCollector()
|
s.metricsCollector = getMetricsCollector()
|
||||||
|
|
||||||
s.setMaxObjectSize(conn.GetMaxObjectSize())
|
s.setMaxObjectSize(conn.GetMaxObjectSize())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue