mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-13 00:17:18 +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
|
||||
}
|
||||
|
||||
var metricsInstance metricsCollector
|
||||
|
||||
func init() { metricsInstance = newS3MetricsCollector() }
|
||||
|
||||
// getMetricsCollector returns the singleton metrics collector instance..
|
||||
func getMetricsCollector() metricsCollector { return metricsInstance }
|
||||
|
||||
func newS3MetricsCollector() metricsCollector {
|
||||
return &collector{
|
||||
objectsScanned: promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
|
|
|
@ -99,7 +99,7 @@ func (s *Source) Init(
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.metricsCollector = newS3MetricsCollector()
|
||||
s.metricsCollector = getMetricsCollector()
|
||||
|
||||
s.setMaxObjectSize(conn.GetMaxObjectSize())
|
||||
|
||||
|
|
Loading…
Reference in a new issue