Skip to content

Log DB query request metrics#4442

Merged
jochenehret merged 2 commits into
mainfrom
codex/add-database-query-metrics-and-logging
Aug 7, 2025
Merged

Log DB query request metrics#4442
jochenehret merged 2 commits into
mainfrom
codex/add-database-query-metrics-and-logging

Conversation

@philippthun

@philippthun philippthun commented Jul 10, 2025

Copy link
Copy Markdown
Member
  • implement Sequel extension for counting DB queries and accumulating DB query times
  • store DB request metrics in thread-local variables
  • reset metrics in the request_metrics middleware (the first one)
  • log metrics on request completion in the request_logs middleware
  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@philippthun philippthun force-pushed the codex/add-database-query-metrics-and-logging branch from 6006476 to e30e7ed Compare July 10, 2025 12:14
@philippthun philippthun force-pushed the codex/add-database-query-metrics-and-logging branch 3 times, most recently from fed7ff1 to a4fdbd8 Compare July 28, 2025 09:02
@philippthun philippthun changed the title Add query count metrics Log DB query request metrics Jul 28, 2025
@philippthun philippthun marked this pull request as ready for review July 28, 2025 09:21
@philippthun philippthun force-pushed the codex/add-database-query-metrics-and-logging branch 3 times, most recently from 6bd6c97 to aae3c62 Compare July 29, 2025 07:39
- number of queries per request
- accumulated query time
@philippthun philippthun force-pushed the codex/add-database-query-metrics-and-logging branch from aae3c62 to 9dcd69e Compare July 29, 2025 11:34

@jochenehret jochenehret left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works fine if log_db_queries is true. If it is false, the keys total_db_query_time_in_ms and db_query_count are logged with constant values 0. time_taken_in_ms is correctly logged. The db_query keys should only be logged if log_db_queries is true.

* if log_db_queries is falses, the two new fields would be logged but always with "0" as value
@jochenehret jochenehret self-requested a review August 7, 2025 11:35
@jochenehret jochenehret merged commit 4dcb0b9 into main Aug 7, 2025
18 of 19 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Aug 7, 2025
Changes in cloud_controller_ng:

- Log DB query request metrics
    PR: cloudfoundry/cloud_controller_ng#4442
    Author: Philipp Thun <philipp.thun@sap.com>
    Author: Jochen Ehret <jochen.ehret@sap.com>
@moleske moleske deleted the codex/add-database-query-metrics-and-logging branch August 7, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants