Class ConnectLogDebouncer
java.lang.Object
app.ductape.sdk.core.observability.ConnectLogDebouncer
TS parity utility mirroring the
VECTOR_LOG_DEBOUNCE_MS,
GRAPH_CONNECT_LOG_DEBOUNCE_MS, and CONNECT_LOG_DEBOUNCE_MS
pattern used in the TypeScript SDK to suppress duplicate
connect/disconnect log rows within a short window.
Each domain instance is keyed by productTag:component:envSlug (mirroring
the TS logKey convention). For each key we track the most recent emission
timestamp for the initiated, success, and failed buckets;
a new emission is only allowed if the previous one is older than
windowMs(). The default window is 15 seconds, matching TS.
Use shouldEmit(String, Bucket) on the hot path: it both checks the
window and (when true) records the new timestamp atomically.
The clock is injectable via withClock(LongSupplier) so parity tests
can advance virtual time without sleeping.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumBucket discriminator for connect/disconnect lifecycle. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longTS parity default window for connect/disconnect log debounce. -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a debouncer with the default 15s TS window.ConnectLogDebouncer(long windowMs) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringTS-stylelogKeyfactory:"{product}:{component}:{env}".voidForget the most recent emissions forkey(e.g.voidresetAll()Forget all emissions (e.g.booleanshouldEmit(String key, ConnectLogDebouncer.Bucket bucket) Returnstrueif a log row for(key, bucket)should be emitted now, stamps the bucket with the current time, and otherwise returnsfalse.longwindowMs()TS parity: 15000ms by default.withClock(LongSupplier clock) Inject a virtual clock for parity tests; passingnullresets to the system clock.
-
Field Details
-
DEFAULT_WINDOW_MS
public static final long DEFAULT_WINDOW_MSTS parity default window for connect/disconnect log debounce.- See Also:
-
-
Constructor Details
-
ConnectLogDebouncer
public ConnectLogDebouncer()Construct a debouncer with the default 15s TS window. -
ConnectLogDebouncer
public ConnectLogDebouncer(long windowMs)
-
-
Method Details
-
windowMs
public long windowMs()TS parity: 15000ms by default. -
withClock
Inject a virtual clock for parity tests; passingnullresets to the system clock. -
shouldEmit
Returnstrueif a log row for(key, bucket)should be emitted now, stamps the bucket with the current time, and otherwise returnsfalse. -
reset
Forget the most recent emissions forkey(e.g. on shutdown / reset). -
resetAll
public void resetAll()Forget all emissions (e.g. between test cases). -
key
TS-stylelogKeyfactory:"{product}:{component}:{env}". Callers are free to construct keys however they like; this helper documents the convention.
-