feat: Database_observability.postgres: support excluding DBs in all collectors#5366
Conversation
ea452a3 to
006566e
Compare
006566e to
51f4afa
Compare
| package collector | ||
|
|
||
| import "strings" | ||
| import "github.com/grafana/alloy/internal/component/database_observability" |
There was a problem hiding this comment.
Most of the code here has been moved to shared sql_exclusion.go
| @@ -0,0 +1,84 @@ | |||
| package database_observability | |||
There was a problem hiding this comment.
Tests moved here from deleted file exclude_schemas_test.go
51f4afa to
197c84b
Compare
| var defaultExclusionClause = buildExclusionClause(defaultExcludedSchemas) | ||
| var defaultExclusionClause = database_observability.BuildExclusionClause(defaultExcludedSchemas) | ||
|
|
||
| func buildExcludedSchemasClause(excludedSchemas []string) string { |
There was a problem hiding this comment.
Can we move this to sql_exclusion given it's pretty generic appending of slices
There was a problem hiding this comment.
As optimisation, the var defaultExclusionClause is precomputed as string and returned by this method, with the default being different for each engine.
We could move everything into sql_exclusion but would need to carry over the engine-specific lists as well in the top package. I don't have a strong preference, wdyt?
There was a problem hiding this comment.
I prefer not to move engine-specifics to top package so let's keep as is. Thanks
There was a problem hiding this comment.
Ok I'll leave as-is. (but I've applied the rename you suggested in the other comment)
| import "strings" | ||
| import "github.com/grafana/alloy/internal/component/database_observability" | ||
|
|
||
| var defaultExcludedSchemas = []string{"mysql", "performance_schema", "sys", "information_schema"} |
There was a problem hiding this comment.
| var defaultExcludedSchemas = []string{"mysql", "performance_schema", "sys", "information_schema"} | |
| var excludedSchemas = []string{"mysql", "performance_schema", "sys", "information_schema"} |
There was a problem hiding this comment.
Have pushed a second commit with the rename.
| var defaultExcludedSchemas = []string{"mysql", "performance_schema", "sys", "information_schema"} | ||
|
|
||
| var defaultExclusionClause = buildExclusionClause(defaultExcludedSchemas) | ||
| var defaultExclusionClause = database_observability.BuildExclusionClause(defaultExcludedSchemas) |
There was a problem hiding this comment.
| var defaultExclusionClause = database_observability.BuildExclusionClause(defaultExcludedSchemas) | |
| var exclusionClause = database_observability.BuildExclusionClause(defaultExcludedSchemas) |
There was a problem hiding this comment.
Same comments as in internal/component/database_observability/mysql/collector/exclude_schemas.go
…ollectors Propagate `exclude_databases` configuration to all PostgreSQL collectors and append the user-defined databases to the default excluded databases. Additionally, change the behaviour of `explain_plans` collector to skip queries from excluded databases instead of processing them. Followup of #5350
197c84b to
9f9fdf8
Compare
…ollectors (#5366) ### Brief description of Pull Request Propagate `exclude_databases` configuration to all PostgreSQL collectors and append the user-defined databases to the default excluded databases. Additionally, change the behaviour of `explain_plans` collector to skip queries from excluded databases instead of processing them. Followup of #5350 ### Pull Request Details <!-- Add a more detailed descripion of the Pull Request here, if needed. --> ### Issue(s) fixed by this Pull Request <!-- Uncomment the following line and fill in an issue number if you want a GitHub issue to be closed automatically when this PR gets merged. --> <!-- Fixes #issue_id --> ### Notes to the Reviewer <!-- Add any relevant notes for the reviewers and testers of this PR. --> ### PR Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [ ] Documentation added - [x] Tests updated - [ ] Config converters updated (cherry picked from commit 1fe42db)
…ollectors [backport] (#5383) ## Backport of #5366 This PR backports #5366 to release/v1.13. ### Original PR Author @cristiangreco ### Description ### Brief description of Pull Request Propagate `exclude_databases` configuration to all PostgreSQL collectors and append the user-defined databases to the default excluded databases. Additionally, change the behaviour of `explain_plans` collector to skip queries from excluded databases instead of processing them. Followup of #5350 ### Pull Request Details <!-- Add a more detailed descripion of the Pull Request here, if needed. --> ### Issue(s) fixed by this Pull Request <!-- Uncomment the following line and fill in an issue number if you want a GitHub issue to be closed automatically when this PR gets merged. --> <!-- Fixes #issue_id --> ### Notes to the Reviewer <!-- Add any relevant notes for the reviewers and testers of this PR. --> ### PR Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [ ] Documentation added - [x] Tests updated - [ ] Config converters updated --- *This backport was created automatically.* Co-authored-by: Cristian Greco <cristian@regolo.cc>
Brief description of Pull Request
Propagate
exclude_databasesconfiguration to all PostgreSQL collectors and append the user-defined databases to the default excluded databases.Additionally, change the behaviour of
explain_planscollector to skip queries from excluded databases instead of processing them.Followup of #5350
Pull Request Details
Issue(s) fixed by this Pull Request
Notes to the Reviewer
PR Checklist