Class DedupAutoConfiguration
Activated when im2be.dedup.enabled=true is set in a consuming
application's application.properties. Wires:
DedupProperties— type-safe config bindingProcessedKafkaEventRepository— Spring Data JPA repositoryDedupMetricsBinder— Micrometer counters + gaugesDedupGuard— the public dedup API bean. Its tracer is resolved per call via aSupplierthat prefers a Spring-beanOpenTelemetry, falls back toGlobalOpenTelemetry.get()(set by the OTel Java Agent), and finally toOpenTelemetry.noop()when no OTel is present.Clock(fallback) — UTC system clock when none is supplied
EntityScan + EnableJpaRepositories are scoped to the
dedup package so the consuming service does NOT need to extend its own
@EntityScan list — the autoconfiguration is self-contained.
Registered via
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionUTC system clock — used byDedupMetricsBinderto determine the "current" week for the active-partitions gauge.dedupGuard(ProcessedKafkaEventRepository repository, DedupMetricsBinder metrics, org.springframework.beans.factory.ObjectProvider<io.opentelemetry.api.OpenTelemetry> otelProvider, Clock clock, DedupProperties props) DedupGuardsingleton — the module's public API.dedupMetricsBinder(io.micrometer.core.instrument.MeterRegistry registry, ProcessedKafkaEventRepository repository, Clock clock) Metrics binder bean.
-
Constructor Details
-
DedupAutoConfiguration
public DedupAutoConfiguration()
-
-
Method Details
-
dedupClock
UTC system clock — used byDedupMetricsBinderto determine the "current" week for the active-partitions gauge. MarkedConditionalOnMissingBeanso test contexts (or services with their own fixed clock) can override.- Returns:
- UTC system clock
-
dedupMetricsBinder
@Bean @ConditionalOnMissingBean public DedupMetricsBinder dedupMetricsBinder(io.micrometer.core.instrument.MeterRegistry registry, ProcessedKafkaEventRepository repository, Clock clock) Metrics binder bean.MeterRegistryis autowired from the host application's Micrometer wiring (Spring Boot Actuator brings a default registry; if none is present the autoconfig fails fast — the dedup module requires observability).- Parameters:
registry- the application's meter registryrepository- the dedup repository for gauge pollingclock- the clock for current-week resolution- Returns:
- a
DedupMetricsBinder
-
dedupGuard
@Bean @ConditionalOnMissingBean public DedupGuard dedupGuard(ProcessedKafkaEventRepository repository, DedupMetricsBinder metrics, org.springframework.beans.factory.ObjectProvider<io.opentelemetry.api.OpenTelemetry> otelProvider, Clock clock, DedupProperties props) DedupGuardsingleton — the module's public API.R3 MINOR fix: the previous version defined a
Tracerbean here that snapshotted theOpenTelemetrybean at bean-creation time — even withObjectProvider.getIfAvailable(), the resolution still fired during this factory method's execution. Replaced with a deferred supplier passed intoDedupGuard; the guard re-resolves the tracer on everytryClaiminvocation, so an OTel SDK registered AFTER this autoconfig completes is honoured.- Parameters:
repository- the JPA repositorymetrics- the Micrometer binderotelProvider- deferred provider — re-resolved per call inside the guard so post-startup OTel SDK registration takes effect without restartclock- the clock used forfirst_seen_atstampingprops- properties (carriesdefaultScopeId)- Returns:
- a fully-wired guard
-