fix(metrics): address PR #11 code review feedback

Major improvements to prometheus-metrics.ts:
- Use custom registry instead of global promClient.register (isolation)
- Remove duplicate localValues - prom-client is now single source of truth
- Fix reset(labels) to respect labels param using remove() instead of reset()
- Migrate Summary class to use prom-client internally
- getMetricsOutput() now uses customRegistry for proper isolation

Fix misleading comments in retry-utils.ts:
- Change "exponential backoff" to "custom progressive backoff"
- Fix comment claiming constants are "from Defaults" (now local)

Breaking changes to getValues()/get() - now async as they query prom-client
This commit is contained in:
Claude
2026-01-20 13:16:43 +00:00
parent b719349c57
commit 4924912f85
2 changed files with 192 additions and 167 deletions
+3 -3
View File
@@ -18,8 +18,8 @@ import { metrics } from './prometheus-metrics.js'
import type { CircuitBreaker } from './circuit-breaker.js'
/**
* Retry configuration with exponential backoff
* Delays in milliseconds: 1s, 2s, 5s, 10s, 20s
* Retry configuration with custom progressive backoff
* Fixed delay steps in milliseconds: 1s 2s 5s 10s 20s
* Defined locally to avoid circular dependency with Defaults
*/
const RETRY_BACKOFF_DELAYS = [1000, 2000, 5000, 10000, 20000]
@@ -669,7 +669,7 @@ export const retryConfigs = {
/**
* Get retry delay with jitter applied
* Uses RETRY_BACKOFF_DELAYS and RETRY_JITTER_FACTOR from Defaults
* Uses RETRY_BACKOFF_DELAYS and RETRY_JITTER_FACTOR defined locally
*
* @param attempt - Current attempt number (1-based)
* @returns Delay in ms with jitter applied