Skip to content

Conversation

belloibrahv
Copy link
Contributor

@belloibrahv belloibrahv commented Sep 27, 2025

Description

This PR implements a comprehensive logging performance optimization by replacing isLevelEnabled guards with Pino's interpolation values (printf-style formatting) across the codebase. The current implementation uses JavaScript string interpolation within conditional guards, which causes performance overhead by building log messages even when the corresponding log level is disabled.

Key improvements:

  • Performance: Eliminates string building overhead for 68 converted cases (50.7% reduction in isLevelEnabled instances)
  • Readability: Removes cluttered conditional logging statements, making code cleaner and more maintainable
  • Consistency: Standardizes logging approach using %s for string interpolation and %o for object interpolation
  • RPC Method Cleanup: Removes redundant trace logging from 20+ @rpcMethod decorated methods since the dispatcher already logs RPC method execution

Files modified: 20 files with 235 deletions and 100 insertions, demonstrating significant code cleanup.

The changes follow the approach outlined in issue #3574 and fully address the requirements of #4080, replacing simple guards while preserving necessary preprocessing cases (JSON.stringify, data censoring, complex object creation).

Related issue(s)

Fixes #4080

Testing Guide

  1. Verify logging functionality: Run the application and confirm that log messages appear at appropriate levels (trace, debug, info, warn) with correct interpolation
  2. Test performance impact: Compare logging performance before and after changes - interpolation values should have negligible overhead compared to previous string building approach
  3. Validate RPC method logging: Confirm that RPC method execution is still properly logged by the dispatcher (redundant @rpcMethod trace logs have been removed)
  4. Check preprocessing preservation: Ensure that cases requiring data preprocessing (censoring, JSON.stringify, complex object access) still maintain proper isLevelEnabled guards
  5. Verify interpolation values: Test that %s and %o placeholders correctly display string and object values respectively

Changes from original design (optional)

N/A

Additional work needed (optional)

  • Performance validation: Consider running K6 tests to validate the performance improvements as mentioned in the original issue requirements
  • Documentation updates: Consider updating logging guidelines in documentation to reflect the new interpolation approach
  • Pre-existing issues: The remaining compilation errors (BigNumber type conflicts, logger method signature issues) are pre-existing and should be addressed in separate PRs

Checklist

  • I've assigned an assignee to this PR and related issue(s) (if applicable)
  • I've assigned a label to this PR and related issue(s) (if applicable)
  • I've assigned a milestone to this PR and related issue(s) (if applicable)
  • I've updated documentation (code comments, README, etc. if applicable)
  • I've done sufficient testing (unit, integration, etc.)

- Replace simple isLevelEnabled guards with Pino interpolation values for better performance
- Remove @rpcMethod trace guards since dispatcher already logs RPC method execution
- Keep guards for cases requiring preprocessing (e.g., data censoring, JSON.stringify)
- Use %s for string interpolation and %o for object interpolation
- Improve code readability by removing unnecessary conditional logging

Fixes hiero-ledger#4080

Signed-off-by: belloibrahv <[email protected]>
@belloibrahv belloibrahv requested review from a team as code owners September 27, 2025 22:46
…n values

- Convert remaining simple cases in repository files
- Replace debug and trace logging with interpolation values
- Maintain guards for cases requiring preprocessing
- Improve logging performance and code readability

Continues work on hiero-ledger#4080

Signed-off-by: belloibrahv <[email protected]>
…n values

- Convert remaining simple cases in config service and eth.ts
- Replace debug and trace logging with interpolation values
- Maintain guards for cases requiring preprocessing (JSON.stringify, complex object access)
- Continue improving logging performance and code readability

Continues work on hiero-ledger#4080

Signed-off-by: belloibrahv <[email protected]>
- Remove @rpcMethod trace guards from newBlockFilter and uninstallFilter
- Convert simple trace cases in repository files and commonService
- Maintain guards for cases requiring preprocessing (JSON.stringify, complex object creation)
- Achieve significant reduction in isLevelEnabled instances

Completes work on hiero-ledger#4080

Signed-off-by: belloibrahv <[email protected]>
- Remove remaining @rpcMethod trace guards from 10+ methods in eth.ts
- Convert simple interpolation cases in mirrorNodeClient.ts
- Fix linting error in EVM_ADDRESS_REGEX
- Achieve 68 instance reduction (134 → 66, 50.7% improvement)
- All remaining 66 instances appropriately preserved for preprocessing

Final comprehensive cleanup for hiero-ledger#4080

Signed-off-by: belloibrahv <[email protected]>
CRITICAL FIX: Remove trace logging from @rpcMethod methods that violates requirements

- Remove trace logs from newPendingTransactionFilter() and submitWork()
- Remove trace logs from getFilterLogs() and getFilterChanges()
- Remove trace log from call() method
- All @rpcMethod methods should NOT have trace logging per issue requirements
- Dispatcher already logs RPC method execution

Fixes compliance with hiero-ledger#4080 requirements

Signed-off-by: belloibrahv <[email protected]>
@belloibrahv
Copy link
Contributor Author

@acuarica @ebadiere @shemnon @shemnon, Please help me review the PR for the issue #4080. I have implemented all the required changes as specified in the issue requirements.

@quiet-node quiet-node added the enhancement New feature or request label Sep 29, 2025
@quiet-node quiet-node added this to the 0.72.0 milestone Sep 29, 2025
@simzzz simzzz modified the milestones: 0.72.0, 0.73.0 Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use "interpolation values" instead of string interpolation when logging
3 participants