Repository navigation
refactor: gate SAP statistics hooks at registration, not per request - #568
Merged
Merged
Conversation
The sap_statistics config is static (read once from cds.env and memoized), so evaluating isSapStatisticsEnabled() once while building the instrumentations is equivalent to the former per-request check. When the feature is off (default) the responseHook wrappers are no longer installed at all; when on, the per-request gate call is gone from the hot path.
Contributor
There was a problem hiding this comment.
🔍 PR Review — refactor: gate SAP statistics hooks at registration, not per request
✅ Looks good! No issues found.
PR Bot Information
Version: 1.33.17
- Correlation ID:
ed508ee0-d39a-11f1-87c9-caed7fe19ec3 - Event Trigger:
pull_request.ready_for_review - File Content Strategy: Full file content
- Experiment Variant:
treatment - LLM:
gpt-5.6-sol
sjvans
marked this pull request as ready for review
October 29, 2026 13:16
Contributor
SummaryThe following content is AI-generated and provides a summary of the pull request: Gate SAP Statistics Hooks During Instrumentation SetupRefactor♻️ Move SAP statistics enablement checks from the per-request response path to instrumentation registration. Disabled configurations no longer install response hook wrappers, while enabled configurations avoid repeated gate checks without changing runtime behavior. Changes
Test Plan
Related Pull Request
PR Bot InformationVersion:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Hoists the
isSapStatisticsEnabled()gate out of the per-requestresponseHookand up to instrumentation registration time in_getInstrumentations(). Also promotes the./tracing/sap_statisticsimport from a lazy in-looprequireto a module-level one.Why
The
sap_statisticsconfig is static:_getConfig()readscds.env.requires.telemetry?.tracing?.sap_statisticsonce and memoizes it, andcds.envdoesn't change at runtime. So evaluating the gate once while building the instrumentations is equivalent to the former per-request check — registration already runs after env resolution (the same function readscds.env.requires.telemetry.loggingunconditionally).Net effect:
responseHookwrappers are no longer installed at all — previously a wrapper ran on every HTTP client response just to call the gate and return.No behavior change for users — the feature already couldn't be toggled after setup (memoized config), so taking the snapshot at registration rather than first request is not a regression. Pure internal cleanup of the beta feature added in #547, so no changelog entry.
Test plan
sap_statisticstests pass (bothhttpandundicipaths, all modes)