Skip to content

feat(factory): expose address cache hit/miss metrics (closes #611) - #685

Open
Ranjeet2063 wants to merge 1 commit into
conduit-protocol:mainfrom
Ranjeet2063:feat/issue-611-cache-metrics
Open

feat(factory): expose address cache hit/miss metrics (closes #611)#685
Ranjeet2063 wants to merge 1 commit into
conduit-protocol:mainfrom
Ranjeet2063:feat/issue-611-cache-metrics

Conversation

@Ranjeet2063

Copy link
Copy Markdown

Summary

Exposes counters tracking cache hits, misses, and current size for the factory address resolution cache (FactoryModule and StreamsModule), enabling consumers and operators to monitor cache performance and tune concurrency and cache sizing (closes #611).

Key Changes

  • src/factory.ts:
    • Defined and exported CacheMetrics interface ({ hits: number; misses: number; size: number }).
    • Added private counters _addressCacheHits and _addressCacheMisses in FactoryModule.
    • Updated streamAddress to record hits (both positive and unexpired negative hits) and misses.
    • Added getAddressCacheMetrics(): CacheMetrics and resetAddressCacheMetrics(): void.
  • src/streams.ts:
    • Added convenience methods getAddressCacheMetrics() and resetAddressCacheMetrics() on StreamsModule delegating to _factory.
  • src/index.ts:
    • Re-exported FactoryModule and type CacheMetrics.
  • src/tests/factory.test.ts:
    • Added 5 comprehensive test cases verifying initial state, positive/negative hit and miss tracking, metric reset, and cache clearing.

Verification

  • vitest run src/tests/factory.test.ts: 24/24 tests passing.
  • Full build (rm -rf dist && tsc -p tsconfig.build.json && rollup -c rollup.config.mjs) passed cleanly.
  • Full vitest suite: 81/81 test files passing (1026 passing tests).

Copilot AI lite review requested due to automatic review settings September 5, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Expose LRU cache hit/miss metrics

2 participants