Skip to content

database_observability: add auto-enable setup consumers to query_sample #3922

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cristiangreco
Copy link
Contributor

PR Description

Introduce a check in the query_sample collector to automatically enable the events_statements_cpu consumer in the performance_schema.setup_consumers table.

This is guarded by two config options:

  • allow_update_performance_schema_settings: to enable "updates" to performance_schema settings altogether.
  • auto_enable_setup_consumers: to start auto-enabling of the setting specific to the query_sample collector.

Which issue(s) this PR fixes

n.a.

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@cristiangreco cristiangreco force-pushed the cristian/dbo11y-query-sample-autoenable-cpu-consumer branch from 941c4f7 to 7219121 Compare June 30, 2025 16:01
DataSourceName alloytypes.Secret `alloy:"data_source_name,attr"`
CollectInterval time.Duration `alloy:"collect_interval,attr,optional"`
ForwardTo []loki.LogsReceiver `alloy:"forward_to,attr"`
EnableCollectors []string `alloy:"enable_collectors,attr,optional"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, (not sure if it's possible), in the future when we have several different setup_consumers we want to configure in a fine-grained manner, will it be easier provide a list to enable/disable similar to EnableCollectors/DisableCollectors?

Might be overengineered, though, so maybe it's better to start with a simple boolean for now that is at the lowest level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm something to think about, but agree to start simple for now as we don't know how widespread this functionality will be.

@fridgepoet
Copy link
Contributor

Should we distinguish because something that "collects" and something that will "write"?

@cristiangreco cristiangreco force-pushed the cristian/dbo11y-query-sample-autoenable-cpu-consumer branch 3 times, most recently from d8e5886 to d5a6d9a Compare July 9, 2025 10:51
Copy link
Contributor

github-actions bot commented Jul 9, 2025

@cristiangreco cristiangreco force-pushed the cristian/dbo11y-query-sample-autoenable-cpu-consumer branch from d5a6d9a to eec1c14 Compare July 9, 2025 10:54
@gaantunes
Copy link
Contributor

I wonder if we should create a separate collector that is responsible for maintaining all write operations based on enabled colletors array (taking into account defaults of course). Detaching it would allow a longer scrape period for these operations, instead of checking/writing every time we do a scrape in each collector.

@cristiangreco cristiangreco force-pushed the cristian/dbo11y-query-sample-autoenable-cpu-consumer branch 2 times, most recently from 22b1cb9 to 221ac06 Compare July 10, 2025 14:32
Introduce a check in the `query_sample` collector to automatically
enable the `events_statements_cpu` consumer in the
`performance_schema.setup_consumers` table.

This is guarded by two config options:
- `allow_update_performance_schema_settings`: to enable "updates" to
performance_schema settings altogether.
- `auto_enable_setup_consumers`: to start auto-enabling of the setting
specific to the `query_sample` collector.
@cristiangreco cristiangreco force-pushed the cristian/dbo11y-query-sample-autoenable-cpu-consumer branch from 221ac06 to 623ef02 Compare July 10, 2025 14:37
@cristiangreco
Copy link
Contributor Author

I wonder if we should create a separate collector that is responsible for maintaining all write operations based on enabled colletors array (taking into account defaults of course). Detaching it would allow a longer scrape period for these operations, instead of checking/writing every time we do a scrape in each collector.

Yes I agree the the two things should not be necessarily tied together. I'd prefer to postpone that for a followup PR though if that's ok (so here we first verify this is working and proves valuable, then optimise it).

Comment on lines +195 to +200
if c.autoEnableSetupConsumers {
if err := c.updateSetupConsumersSettings(ctx); err != nil {
return err
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented by @gaantunes we could decouple the update from the regular collector loop. I'm keen to postpone that work for a followup PR, here I'm more interested in the correctness of the approach.

@cristiangreco cristiangreco marked this pull request as ready for review July 11, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants