Repository navigation
feat: decouple Prometheus metrics adapter - #56
Merged
Merged
Conversation
lan17
force-pushed
the
agent/decouple-prometheus
branch
from
July 17, 2026 06:25
6f43297 to
2e7d422
Compare
lan17
force-pushed
the
agent/decouple-prometheus
branch
from
July 17, 2026 19:16
2e7d422 to
0d1c80a
Compare
lan17
marked this pull request as ready for review
July 17, 2026 20:10
This was referenced Jul 17, 2026
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.
Summary
Makes DialCache metrics explicitly opt-in and removes Prometheus from the core package boundary.
metricsis omitted fromnew DialCache().DialCacheMetricsAdapterremains in the root API.dialcache/prometheussubpath.prom-clientseparately and pass a caller-owned registry.Closes #53
Architecture and design
Backend-neutral core
Core owns only the cache-domain metrics contract, label/event types, instrumentation call sites, and synchronous fail-open isolation.
DialCacheConfigexposes one optional field:Omitting that field stores no adapter, imports no metrics backend, and registers no collectors. The redundant
metrics: falsemode and Prometheus-specificmetricsRegistry/metricsPrefixconstructor fields are removed.The root source, ESM/CJS bundles, and declarations contain no runtime or type dependency on
prom-client.Explicit Prometheus adapter
The Prometheus mapping lives at
dialcache/prometheusand exports:PrometheusDialCacheMetricscreatePrometheusDialCacheMetricsPrometheusMetricsOptionsPrometheusMetricsOptions.registryis required. Prometheus and OpenMetrics registries are supported. The adapter never falls back to the global default registry and does not clear or own the caller's registry lifecycle.Multiple adapters with the same registry and prefix reuse collectors only when their type, help, ordered labels, histogram buckets, and exemplar mode are compatible. All existing collectors are validated before any new DialCache collector is registered, so incompatible collisions fail transactionally with guidance to use a unique prefix or separate registry. Exemplar-enabled collectors are rejected because
prom-clientchanges their call signatures; omitted,false, and explicitundefinedexemplar modes are treated as disabled.This does not change the public metrics schema. The post-request-local schema remains intact, including
layer="request_local"and coalescingscope="request_local" | "process".Dependency and installation model
prom-clientmoves from required production dependency to optional peer plus development dependency. This matches the separately installed, caller-owned Redis integration model.The packed-package suite proves two consumer modes:
prom-clientand Valkey GLIDE are physically absent.prom-client, including caller-owned Prometheus and OpenMetrics registries.The suite also asserts that removed constructor fields and
metrics: falseare absent from the public type surface and that Prometheus exports are absent from the root module.API migration
new DialCache()implicitly registered Prometheus collectorsnew DialCache()has metrics disablednew DialCache({ metrics: false })new DialCache()new DialCache({ metricsRegistry, metricsPrefix })new DialCache({ metrics: createPrometheusDialCacheMetrics({ registry, prefix }) })dialcachedialcache/prometheusNo Redis data, cache key, serializer, invalidation, or wire-protocol migration is required.
Review-loop hardening
main.Validation
Exact head:
47ae82b8b8904a855eb4575edbd044aa16f1a1cecorepack pnpm checkon Node v22.22.0corepack pnpm test:integrationcorepack pnpm benchmark:request-localcorepack pnpm audit --prod --audit-level highgit diff --checkpassed.