@@ -24,6 +24,7 @@ type postgreSQLScraper struct {
24
24
config * Config
25
25
clientFactory postgreSQLClientFactory
26
26
mb * metadata.MetricsBuilder
27
+ excludes map [string ]struct {}
27
28
}
28
29
type errsMux struct {
29
30
sync.RWMutex
@@ -69,11 +70,16 @@ func newPostgreSQLScraper(
69
70
config * Config ,
70
71
clientFactory postgreSQLClientFactory ,
71
72
) * postgreSQLScraper {
73
+ excludes := make (map [string ]struct {})
74
+ for _ , db := range config .ExcludeDatabases {
75
+ excludes [db ] = struct {}{}
76
+ }
72
77
return & postgreSQLScraper {
73
78
logger : settings .Logger ,
74
79
config : config ,
75
80
clientFactory : clientFactory ,
76
81
mb : metadata .NewMetricsBuilder (config .MetricsBuilderConfig , settings ),
82
+ excludes : excludes ,
77
83
}
78
84
}
79
85
@@ -102,13 +108,9 @@ func (p *postgreSQLScraper) scrape(ctx context.Context) (pmetric.Metrics, error)
102
108
}
103
109
databases = dbList
104
110
}
105
- exclude := make (map [string ]struct {})
106
- for _ , db := range p .config .ExcludeDatabases {
107
- exclude [db ] = struct {}{}
108
- }
109
111
var filteredDatabases []string
110
112
for _ , db := range databases {
111
- if _ , ok := exclude [db ]; ! ok {
113
+ if _ , ok := p . excludes [db ]; ! ok {
112
114
filteredDatabases = append (filteredDatabases , db )
113
115
}
114
116
}
0 commit comments