Skip to content

Commit 8577876

Browse files
committed
use string array
Signed-off-by: Cristian Greco <cristian@regolo.cc>
1 parent 0314fdd commit 8577876

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

collector/perf_schema_events_statements.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ var (
142142
perfEventsStatementsExcludeSchemas = kingpin.Flag(
143143
"collect.perf_schema.eventsstatements.exclude_schemas",
144144
"Comma-separated list of additional schema names to exclude (always excludes mysql, performance_schema, information_schema)",
145-
).Default("").String()
145+
).Default("").Strings()
146146
)
147147

148148
var defaultExcludedSchemas = []string{"'mysql'", "'performance_schema'", "'information_schema'"}
@@ -360,18 +360,16 @@ func (ScrapePerfEventsStatements) Scrape(ctx context.Context, instance *instance
360360
return nil
361361
}
362362

363-
func buildExcludedSchemasList(extraSchemas string) string {
363+
func buildExcludedSchemasList(extraSchemas []string) string {
364364
if len(extraSchemas) == 0 {
365365
return strings.Join(defaultExcludedSchemas, ", ")
366366
}
367367

368368
excludedSchemas := slices.Clone(defaultExcludedSchemas)
369-
for s := range strings.SplitSeq(extraSchemas, ",") {
370-
if trimmed := strings.TrimSpace(s); trimmed != "" {
371-
escaped := "'" + strings.ReplaceAll(trimmed, "'", "''") + "'"
372-
if !slices.Contains(excludedSchemas, escaped) {
373-
excludedSchemas = append(excludedSchemas, escaped)
374-
}
369+
for _, s := range extraSchemas {
370+
escaped := "'" + strings.ReplaceAll(s, "'", "''") + "'"
371+
if !slices.Contains(excludedSchemas, escaped) {
372+
excludedSchemas = append(excludedSchemas, escaped)
375373
}
376374
}
377375

0 commit comments

Comments
 (0)