apache/seatunnel · warning
Unable to initialize metrics context for file source enumera
Error message
Unable to initialize metrics context for file source enumerator.
What it means
The ContinuousMultipleTableFileSourceSplitEnumerator constructor tries to obtain a MetricsContext from the enumerator context to initialize its post-sync counters. If context.getMetricsContext() throws any exception, it logs this warning, keeps metricsContext as null, and continues. The counters become inert (initCounter handles null), so metrics reporting for post-sync operations is lost but the job still runs.
Source
Thrown at seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/split/ContinuousMultipleTableFileSourceSplitEnumerator.java:156
FileSplitStrategy fileSplitStrategy) {
this(
context,
multipleTableFileSourceConfig,
fileSplitStrategy,
new FileSourceState(new HashSet<>()));
}
public ContinuousMultipleTableFileSourceSplitEnumerator(
Context<FileSourceSplit> context,
BaseMultipleTableFileSourceConfig multipleTableFileSourceConfig,
FileSplitStrategy fileSplitStrategy,
FileSourceState checkpointState) {
this.context = context;
MetricsContext metricsContext = null;
try {
metricsContext = context.getMetricsContext();
} catch (Exception e) {
log.warn("Unable to initialize metrics context for file source enumerator.", e);
}
this.postSyncSubmittedCounter = initCounter(metricsContext, METRIC_POST_SYNC_SUBMITTED);
this.postSyncSucceededCounter = initCounter(metricsContext, METRIC_POST_SYNC_SUCCEEDED);
this.postSyncFailedCounter = initCounter(metricsContext, METRIC_POST_SYNC_FAILED);
this.postSyncStaleSkippedCounter =
initCounter(metricsContext, METRIC_POST_SYNC_STALE_SKIPPED);
this.retentionDeletedCounter = initCounter(metricsContext, METRIC_RETENTION_DELETED);
this.retentionFailedCounter = initCounter(metricsContext, METRIC_RETENTION_FAILED);
this.jobStartTimeMillis =
checkpointState.getDiscoveryStartTimeMillis() > 0
? checkpointState.getDiscoveryStartTimeMillis()
: System.currentTimeMillis();
Set<FileSourceSplit> restoredInFlightSplits =
new HashSet<>(checkpointState.getAssignedSplit());
this.inFlightSplits = new HashSet<>();
List<BaseFileSourceConfig> fileSourceConfigs =View on GitHub (pinned to cf67b549a7)
Solutions
- Check the wrapped exception (logged with this warning) to find why getMetricsContext() threw and fix the runtime/metrics configuration
- Upgrade or align the SeaTunnel engine version so the metrics context is provided to split enumerators
- Ignore safely if metrics are not needed — the enumerator continues with null counters
Defensive patterns
Strategy: fallback
Type guard
// Treat metrics as optional everywhere
if (metricsContext != null) {
counter = metricsContext.getCounter(name);
} else {
counter = noopCounter;
} Try / catch
try {
metricsContext = context.getMetricsContext();
} catch (Exception e) {
log.warn("Unable to initialize metrics context for file source enumerator.", e);
metricsContext = null; // counters degrade to no-ops
} Prevention
- Run on an engine/runtime version that provides MetricsContext to split enumerators
- When writing test harnesses, implement getMetricsContext() instead of throwing
- Treat missing metrics as non-fatal and monitor for this warning to catch wiring regressions
When it happens
Trigger: Constructing the enumerator with a context whose getMetricsContext() throws — e.g. an engine/runtime version or test harness that does not provide a metrics context, or a metrics subsystem initialization failure in the runtime.
Common situations: Running the continuous file source on a runtime where the metrics context API is unavailable or not wired; unit-test contexts that throw from getMetricsContext; engine upgrades changing the metrics SPI.
Related errors
- CONFIG_VALIDATION_FAILED
- Skip post-sync staging because table context is not found. s
- Unsupported handleSplitRequest: %d
- UNSUPPORTED_OPERATION
- FILE_LIST_GET_FAILED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/65513da7cc78f54d.
Report an issue: GitHub.