Package com.aim2be.platform.dedup
Class DedupMetricsBinder
java.lang.Object
com.aim2be.platform.dedup.DedupMetricsBinder
Micrometer binder for the dedup module.
Metrics published:
im2be_dedup_claims_total— counter, tagsconsumer_scope_id,outcome∈claimed | duplicate. One increment perDedupGuard.tryClaim(java.lang.String, java.lang.String, java.time.Instant, java.lang.String, int, long)call.im2be_dedup_active_partitions_total— gauge perconsumer_scope_id. PollsProcessedKafkaEventRepository.countByIdConsumerScopeIdAndIdWeekStart(java.lang.String, java.time.LocalDate)for the current week (per the binder'sClock). Operationally surfaces how full the live dedup partition is — valuable for capacity planning and for verifyingpg_partmanretention is keeping pace.
Counter and gauge instances are lazily created per
consumer_scope_id and cached for the lifetime of the binder.
Cardinality is bounded by the number of distinct logical consumers (8
services on day 1; up to ~32 in the per-pod broadcast scenario per
ADR-0014 §L-12 — well within Prometheus' recommended series-per-metric
budget).
-
Constructor Summary
ConstructorsConstructorDescriptionDedupMetricsBinder(io.micrometer.core.instrument.MeterRegistry registry, ProcessedKafkaEventRepository repository, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionvoidrecordClaim(String consumerScopeId, String outcome) Increment theim2be_dedup_claims_totalcounter for the given scope + outcome.voidregisterGaugeIfAbsent(String consumerScopeId) Eagerly register a gauge for a scope ahead of any tryClaim traffic.
-
Constructor Details
-
DedupMetricsBinder
public DedupMetricsBinder(io.micrometer.core.instrument.MeterRegistry registry, ProcessedKafkaEventRepository repository, Clock clock) - Parameters:
registry- Micrometer registry to publish into (must not benull)repository- repository for the gauge's count-by-week query (must not benull)clock- clock used to determine the "current" week for the gauge; passClock.systemUTC()in production, a fixed clock in tests
-
-
Method Details
-
recordClaim
Increment theim2be_dedup_claims_totalcounter for the given scope + outcome. Called once perDedupGuard.tryClaim(java.lang.String, java.lang.String, java.time.Instant, java.lang.String, int, long)invocation.- Parameters:
consumerScopeId- logical consumer identityoutcome-DedupGuard.OUTCOME_CLAIMEDorDedupGuard.OUTCOME_DUPLICATE
-
registerGaugeIfAbsent
Eagerly register a gauge for a scope ahead of any tryClaim traffic. Useful in tests or in services that want the gauge visible at startup.- Parameters:
consumerScopeId- scope to register
-