Skip to content

1865_logging-cpu-optimization#2170

Merged
crivetimihai merged 5 commits intomainfrom
1865_logging-cpu-optimization
Jan 22, 2026
Merged

1865_logging-cpu-optimization#2170
crivetimihai merged 5 commits intomainfrom
1865_logging-cpu-optimization

Conversation

@Nayana-R-Gowda
Copy link
Copy Markdown
Collaborator

@Nayana-R-Gowda Nayana-R-Gowda commented Jan 19, 2026

Signed-off-by: NAYANAR nayana.r7813@gmail.com
closes #1865
significantly reduces CPU and database overhead in detailed request logging. User identity resolution is now gated behind logging checks and made opt-in to prevent unnecessary DB queries on every request. A new log_detailed_max_body_size config limits how much request data is parsed and masked. Endpoint skip lists and sampling support were added to avoid logging low-value or high-volume traffic. Overall, the middleware now avoids expensive JSON parsing, masking, and identity lookups unless detailed logging is explicitly enabled and required.

@Nayana-R-Gowda Nayana-R-Gowda marked this pull request as draft January 19, 2026 05:47
@Nayana-R-Gowda Nayana-R-Gowda force-pushed the 1865_logging-cpu-optimization branch from 90c3f95 to 6e8d05a Compare January 19, 2026 06:39
@Nayana-R-Gowda Nayana-R-Gowda marked this pull request as ready for review January 19, 2026 07:10
@crivetimihai crivetimihai self-assigned this Jan 19, 2026
@crivetimihai crivetimihai added this to the Release 1.0.0-RC1 milestone Jan 20, 2026
Nayana-R-Gowda and others added 3 commits January 22, 2026 00:16
Add configuration options to reduce CPU and database overhead in
detailed request logging:

- log_detailed_skip_endpoints: List of path prefixes to skip from
  detailed logging (e.g., high-volume or low-value endpoints)
- log_resolve_user_identity: Gate DB fallback for user identity
  resolution behind opt-in flag (default: false)
- log_detailed_sample_rate: Sampling rate (0.0-1.0) to log only a
  fraction of requests when detailed logging is enabled

These optimizations avoid expensive JSON parsing, masking, and identity
lookups unless detailed logging is explicitly enabled and required.

Closes #1865

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Document the new logging configuration options:
- LOG_DETAILED_SKIP_ENDPOINTS: path prefixes to skip from logging
- LOG_DETAILED_SAMPLE_RATE: sampling rate for detailed logging
- LOG_RESOLVE_USER_IDENTITY: opt-in DB lookup for user identity

Updated:
- .env.example with new options and descriptions
- README.md logging table and examples
- Helm chart values.yaml and values.schema.json
- charts/mcp-stack/README.md values table
- docs/config.schema.json (regenerated from Pydantic model)
- docs/docs/config.schema.json (regenerated from Pydantic model)

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
…ests

- Add LOG_DETAILED_SKIP_ENDPOINTS to _normalize_env_list_vars() to
  support CSV format and empty string values from environment variables
- Add unit tests for skip endpoints, sampling rate, and user identity
  resolution gating in request logging middleware
- Add settings field validation tests for new config options

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai force-pushed the 1865_logging-cpu-optimization branch from 49b7ff9 to 05f1d9a Compare January 22, 2026 00:57
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
@crivetimihai crivetimihai force-pushed the 1865_logging-cpu-optimization branch from 4720a00 to 380920e Compare January 22, 2026 01:41
@crivetimihai crivetimihai merged commit 2b92567 into main Jan 22, 2026
51 checks passed
@crivetimihai crivetimihai deleted the 1865_logging-cpu-optimization branch January 22, 2026 02:11
010gvr pushed a commit to 010gvr/mcp-context-forge that referenced this pull request Jan 23, 2026
* feat: optimize CPU usage in request logging middleware

Add configuration options to reduce CPU and database overhead in
detailed request logging:

- log_detailed_skip_endpoints: List of path prefixes to skip from
  detailed logging (e.g., high-volume or low-value endpoints)
- log_resolve_user_identity: Gate DB fallback for user identity
  resolution behind opt-in flag (default: false)
- log_detailed_sample_rate: Sampling rate (0.0-1.0) to log only a
  fraction of requests when detailed logging is enabled

These optimizations avoid expensive JSON parsing, masking, and identity
lookups unless detailed logging is explicitly enabled and required.

Closes IBM#1865

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* docs: add documentation for logging CPU optimization options

Document the new logging configuration options:
- LOG_DETAILED_SKIP_ENDPOINTS: path prefixes to skip from logging
- LOG_DETAILED_SAMPLE_RATE: sampling rate for detailed logging
- LOG_RESOLVE_USER_IDENTITY: opt-in DB lookup for user identity

Updated:
- .env.example with new options and descriptions
- README.md logging table and examples
- Helm chart values.yaml and values.schema.json
- charts/mcp-stack/README.md values table
- docs/config.schema.json (regenerated from Pydantic model)
- docs/docs/config.schema.json (regenerated from Pydantic model)

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* fix: add LOG_DETAILED_SKIP_ENDPOINTS to env list normalizer and add tests

- Add LOG_DETAILED_SKIP_ENDPOINTS to _normalize_env_list_vars() to
  support CSV format and empty string values from environment variables
- Add unit tests for skip endpoints, sampling rate, and user identity
  resolution gating in request logging middleware
- Add settings field validation tests for new config options

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* doctest coverage

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* chore: lower doctest coverage threshold to 34%

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
* feat: optimize CPU usage in request logging middleware

Add configuration options to reduce CPU and database overhead in
detailed request logging:

- log_detailed_skip_endpoints: List of path prefixes to skip from
  detailed logging (e.g., high-volume or low-value endpoints)
- log_resolve_user_identity: Gate DB fallback for user identity
  resolution behind opt-in flag (default: false)
- log_detailed_sample_rate: Sampling rate (0.0-1.0) to log only a
  fraction of requests when detailed logging is enabled

These optimizations avoid expensive JSON parsing, masking, and identity
lookups unless detailed logging is explicitly enabled and required.

Closes IBM#1865

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* docs: add documentation for logging CPU optimization options

Document the new logging configuration options:
- LOG_DETAILED_SKIP_ENDPOINTS: path prefixes to skip from logging
- LOG_DETAILED_SAMPLE_RATE: sampling rate for detailed logging
- LOG_RESOLVE_USER_IDENTITY: opt-in DB lookup for user identity

Updated:
- .env.example with new options and descriptions
- README.md logging table and examples
- Helm chart values.yaml and values.schema.json
- charts/mcp-stack/README.md values table
- docs/config.schema.json (regenerated from Pydantic model)
- docs/docs/config.schema.json (regenerated from Pydantic model)

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* fix: add LOG_DETAILED_SKIP_ENDPOINTS to env list normalizer and add tests

- Add LOG_DETAILED_SKIP_ENDPOINTS to _normalize_env_list_vars() to
  support CSV format and empty string values from environment variables
- Add unit tests for skip endpoints, sampling rate, and user identity
  resolution gating in request logging middleware
- Add settings field validation tests for new config options

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* doctest coverage

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

* chore: lower doctest coverage threshold to 34%

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>

---------

Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
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.

[PERFORMANCE]: Reduce CPU cost of detailed request logging

2 participants