Skip to content

feat(diagnostics): implement unified DiagnosticsModule - #412

Merged
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
Truphile:feature/diagnostics-module
Jul 28, 2026
Merged

feat(diagnostics): implement unified DiagnosticsModule#412
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
Truphile:feature/diagnostics-module

Conversation

@Truphile

Copy link
Copy Markdown
Contributor

Here is a summary of the work accomplished:

1. DiagnosticsModule Implementation

• Created src/diagnostics/DiagnosticsModule.ts (and its types), which acts
as a central aggregator and event emitter.
• The module exposes getSnapshot(), which provides a holistic snapshot
encompassing:
• In-Flight Requests: Counts active requests to help track
deduplication behavior.
• Cache Statistics: Simple hit/miss counters.
• Rate Limits: Real-time throttling limits and current rate consumption.
• Circuit Breakers: Maps URLs to their respective health (open status,
failure count, cooldowns, latency).

2. Event Emitter

• The module provides .on(), .off(), and .emit() methods.
• Available events include circuitOpen, circuitClosed, rateLimitThrottled,
cacheHit, and cacheMiss.

3. Decoupled Aggregation

• Instead of subsystems like TokenBucket or HealthTracker needing to import
the DiagnosticsModule directly, we've used an observer pattern.
• Subsystems simply provide registration callbacks via their configs (e.g.,
onThrottled for rate limits or onCircuitOpen for circuit breakers) and the
GuildPassClient acts as the orchestrator to map those callbacks back to the
DiagnosticsModule's emitter.
• We also registered state provider functions (registerInFlightRequests,
registerRateLimit, etc.) on the Diagnostics module, ensuring the
diagnostics module observes the subcomponents, preventing circular
dependencies.

4. Tests and Validation

• Added tests/diagnostics.test.ts to ensure that getSnapshot() works
properly with at least three tracked operational states and that events
accurately fire for state transitions (e.g. simulating a circuit trip
manually triggering onCircuitOpen).
• Fixed all TS type and compilation errors resulting from strict event
typing and new properties.

closes #311

@Lakes41
Lakes41 merged commit 894e169 into Adamantine-guild:main Jul 28, 2026
1 check passed
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.

Design and implement a unified observability/diagnostics module

2 participants