-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database_observability: make collectors configurable #2530
Merged
+200
−40
Merged
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3adef90
Add logger to ConnectionInfo
fridgepoet 4f8fb73
Add enable collectors option
fridgepoet 6a20b35
Add logger to test
fridgepoet 86fa050
Merge remote-tracking branch 'origin/main' into db-o11y-add-enabled-c…
fridgepoet 2e6e6fc
polish up PR and add disable collectors
fridgepoet 2146423
add collector
fridgepoet 3e3943a
Remove a comment
fridgepoet 07d577c
Revert "Add logger to ConnectionInfo"
fridgepoet 26aec8d
Revert "Add logger to test"
fridgepoet 65ea414
update changelog
fridgepoet ddf1607
fix condition
fridgepoet 5ded38f
Update docs, change collector strings
fridgepoet 6d5818a
Add to changelog
fridgepoet b0cea25
Fix format in changelog
fridgepoet 1f179e6
Use collector constants, remove for loop
fridgepoet 076cf25
Merge remote-tracking branch 'origin/main' into db-o11y-add-enabled-c…
fridgepoet cb61613
Remove formatting of const in component
fridgepoet a63e3e7
Merge branch 'main' into db-o11y-add-enabled-collectors
fridgepoet 3c4f0da
Update docs/sources/reference/components/database_observability/datab…
fridgepoet 070a3c5
Update docs/sources/reference/components/database_observability/datab…
fridgepoet a41ab55
Merge remote-tracking branch 'origin/main' into db-o11y-add-enabled-c…
fridgepoet 2123d31
Remove link about collectors which has been moved below the table alr…
fridgepoet 08b305a
Remove redundant enabled by default column
fridgepoet 9169397
Merge branch 'main' into db-o11y-add-enabled-collectors
fridgepoet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
internal/component/database_observability/mysql/component_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package mysql | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/grafana/alloy/syntax" | ||
) | ||
|
||
func Test_enableOrDisableCollectors(t *testing.T) { | ||
t.Run("nothing specified (default behavior)", func(t *testing.T) { | ||
var exampleDBO11yAlloyConfig = ` | ||
data_source_name = "" | ||
forward_to = [] | ||
` | ||
|
||
var args Arguments | ||
err := syntax.Unmarshal([]byte(exampleDBO11yAlloyConfig), &args) | ||
require.NoError(t, err) | ||
|
||
actualCollectors := enableOrDisableCollectors(args) | ||
|
||
assert.Equal(t, map[string]bool{ | ||
querySample: true, | ||
schemaTable: true, | ||
}, actualCollectors) | ||
}) | ||
|
||
t.Run("enable collectors", func(t *testing.T) { | ||
var exampleDBO11yAlloyConfig = ` | ||
data_source_name = "" | ||
forward_to = [] | ||
enable_collectors = ["query_sample", "schema_table"] | ||
` | ||
|
||
var args Arguments | ||
err := syntax.Unmarshal([]byte(exampleDBO11yAlloyConfig), &args) | ||
require.NoError(t, err) | ||
|
||
actualCollectors := enableOrDisableCollectors(args) | ||
|
||
assert.Equal(t, map[string]bool{ | ||
querySample: true, | ||
schemaTable: true, | ||
}, actualCollectors) | ||
}) | ||
|
||
t.Run("disable collectors", func(t *testing.T) { | ||
var exampleDBO11yAlloyConfig = ` | ||
data_source_name = "" | ||
forward_to = [] | ||
disable_collectors = ["query_sample", "schema_table"] | ||
` | ||
|
||
var args Arguments | ||
err := syntax.Unmarshal([]byte(exampleDBO11yAlloyConfig), &args) | ||
require.NoError(t, err) | ||
|
||
actualCollectors := enableOrDisableCollectors(args) | ||
|
||
assert.Equal(t, map[string]bool{ | ||
querySample: false, | ||
schemaTable: false, | ||
}, actualCollectors) | ||
}) | ||
|
||
t.Run("enable collectors takes precedence over disable collectors", func(t *testing.T) { | ||
var exampleDBO11yAlloyConfig = ` | ||
data_source_name = "" | ||
forward_to = [] | ||
disable_collectors = ["query_sample", "schema_table"] | ||
enable_collectors = ["query_sample", "schema_table"] | ||
` | ||
|
||
var args Arguments | ||
err := syntax.Unmarshal([]byte(exampleDBO11yAlloyConfig), &args) | ||
require.NoError(t, err) | ||
|
||
actualCollectors := enableOrDisableCollectors(args) | ||
|
||
assert.Equal(t, map[string]bool{ | ||
querySample: true, | ||
schemaTable: true, | ||
}, actualCollectors) | ||
}) | ||
|
||
t.Run("enabling one and disabling one", func(t *testing.T) { | ||
var exampleDBO11yAlloyConfig = ` | ||
data_source_name = "" | ||
forward_to = [] | ||
disable_collectors = ["schema_table"] | ||
enable_collectors = ["query_sample"] | ||
` | ||
|
||
var args Arguments | ||
err := syntax.Unmarshal([]byte(exampleDBO11yAlloyConfig), &args) | ||
require.NoError(t, err) | ||
|
||
actualCollectors := enableOrDisableCollectors(args) | ||
|
||
assert.Equal(t, map[string]bool{ | ||
querySample: true, | ||
schemaTable: false, | ||
}, actualCollectors) | ||
}) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat preview feature. See changes here https://deploy-preview-alloy-2530-zb444pucvq-vp.a.run.app/docs/alloy/latest/reference/components/database_observability/database_observability.mysql/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!