Skip to main content

Reporter

Reporter is responsible for batching and transmitting collected signals to the Sentinel backend (POST /sen/ss). It supports both time-based and size-based flush triggers, with automatic retry on failure.

Responsibilities

ResponsibilityDetail
Batch flushSends accumulated signals when a threshold is met
Time-based intervalPeriodic forced flush at signalThresholdMs intervals
Size-based triggerImmediate flush when unsent signal count exceeds signalThresholdSize
Token rotationStores any new token returned by the server
Config propagationForwards any new config from the server to Sentinel.updateConfig()
Retry with back-offUses RetryQueue for resilient delivery

Flush Triggers

TriggerConditionForce?
Signal addedunsentSignals.length >= sizeThresholdNo (respects threshold)
Interval timerEvery timeThresholdMs millisecondsYes (flushes any pending signals)
App foregroundAppStateCollector detects tab activationYes

Public API

MethodSignatureDescription
start() => voidBegin periodic flushing (requires thresholds to be set)
stop() => voidStop periodic flushing
flushIfNeeded(force?: boolean) => Promise<void>Flush signals if threshold met, or immediately if force = true
setThresholds(thresholds: ReporterThresholds) => voidUpdate time/size thresholds and reschedule interval

Flush Payload

interface ReporterRequest {
data: {
token: string;
signals: Array<Signal>;
};
}

Signals are sliced to sizeThreshold per flush call. The request is sent to POST /sen/ss on the fsp domain.

Flush Response

interface ReporterResponse {
data: {
token: string;
config: SentinelConfig;
};
}

On success:

  1. New token is stored via TokenManager.
  2. New config is applied via Sentinel.updateConfig()ConfigManager.
  3. Sent signal IDs are removed from SignalStore.

Concurrency Control

The reporter uses a isFlushing flag to prevent overlapping flush calls. If flushIfNeeded is called while a flush is in progress, a pendingFlush flag is set. Once the current flush completes, the pending flush is re-triggered.

Retry Strategy

Each flush is wrapped in a RetryQueue:

ParameterValue
Max attempts3
Base delay200 ms
Back-offExponential (200ms → 400ms → 800ms)

If all retries fail, sen.reporter_flush_failed is logged and the signals remain in the store for the next attempt.

Threshold Lifecycle

Thresholds are initially null. start() is a no-op until setThresholds() has been called. This prevents premature flushing before the server config arrives.

When thresholds are updated while the reporter is running, the interval timer is rescheduled with the new timeThresholdMs.


Last updated: 2026-02-24