Skip to content

[IMP] sql_db: Add optional traceback logging for SELECT queries#624

Open
hbto wants to merge 1 commit intoVauxoo:12.0from
vauxoo-dev:12.0-task57539-traceback_extract-hbto
Open

[IMP] sql_db: Add optional traceback logging for SELECT queries#624
hbto wants to merge 1 commit intoVauxoo:12.0from
vauxoo-dev:12.0-task57539-traceback_extract-hbto

Conversation

@hbto
Copy link

@hbto hbto commented May 7, 2025

[IMP] sql_db: Add optional traceback logging for SELECT queries when enabled via config parameter

This commit adds support for logging the Python stack trace whenever a SELECT query is executed, provided the system parameter vauxoo.traceback.extract_stack is set to '1', 'true', or 'True'.

The traceback is captured using traceback.extract_stack() and logged at the INFO level via _logger.info.

This functionality is intended for debugging purposes to trace the origin of database reads. It can be particularly useful during development or troubleshooting to identify unexpected or inefficient query execution.

⚠️ WARNING: Enabling this in production environments is discouraged, as it may generate extensive log output and potentially impact performance for frequently executed queries.

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

…enabled via config parameter

This commit adds support for logging the Python stack trace whenever a
SELECT query is executed, provided the system parameter
`vauxoo.traceback.extract_stack` is set to '1', 'true', or 'True'.

The traceback is captured using `traceback.extract_stack()` and logged
at the INFO level via `_logger.info`.

This functionality is intended for debugging purposes to trace the
origin of database reads. It can be particularly useful during
development or troubleshooting to identify unexpected or inefficient
query execution.

⚠️ **WARNING**: Enabling this in production environments is discouraged,
as it may generate extensive log output and potentially impact
performance for frequently executed queries.
@hbto hbto force-pushed the 12.0-task57539-traceback_extract-hbto branch from a6cc549 to 69c2386 Compare May 9, 2025 22:04
if _extract_stack_checked:
return _extract_stack_enabled

with _stack_lock:
Copy link
Collaborator

Choose a reason for hiding this comment

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

why we need a thread? don't get it

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.

2 participants