DanielLeens commented on PR #13642: URL: https://github.com/apache/seatunnel/pull/13642#issuecomment-7240397664
## Implementation Notes and Trade-offs Head: `afa2979ad9080218a762c2ecc73aed809ad5cc29` The missing exports are in the telemetry layer: the resource manager already owns slot counts, and coordinator/history state already identifies submissions. The existing aggregate exporter introduced in #7564 exposes only `job_count` by status. REST capacity came through #6883; neither path provides a logical-job recovery ledger. This PR adds two collectors registered by `ExportsInstanceInitializer` and one telemetry-only bounded snapshot reader in `JobHistoryService`; `JobMetricExports` and its distributed aggregate count path remain unchanged. The selected design emits cluster fixed-slot gauges from one observed worker-profile collection and omits dynamic/mixed capacity. Job status is opt-in, labeled by ID and display name, with explicit numeric status codes and submission timestamps. Active state takes precedence over pending/history by ID. Terminal states from both still-owned JobMasters and retained history share a five-minute window and a 1000-record cap. `keySet(PagingPredicate)` selects existing comparable Long keys, followed by a built-in six-field projection for those IDs, avoiding nested pipeline/task payloads and new wire types; a conservative overflow gauge prevents treating a partial terminal set as complete. `Describable` prevents registry registration from making distributed history calls. Final master/readiness checks discard samples if ownership changes during collection. Alternatives actually evaluated: - Extend or relabel aggregate `job_count`: rejected because it changes an existing metric contract and still cannot identify logical recovery. - Emit all retained per-job history through `getJobStatusData()`: rejected because it materializes the entire archive and exposes history-sized series by default. The opt-in query returns one bounded recent page instead; it still scans retained data on owners and does not claim bounded scan CPU. - Automatically suppress failures using a matching name or the newest visible name: rejected because names are not unique identities, and delayed old terminal transitions plus finite windows can produce incorrect recovery claims. Explicit current-attempt ownership stays with the submitting application; the docs show how to match that mapping in PromQL. - Use `values(PagingPredicate)`: rejected because it requires natural ordering of non-Comparable JobState values. Key paging uses existing Long-key ordering; direct projection rejects a paging predicate, so bounded key selection and projection are two queries. Projection results are reordered by selected ID and time bounds are rechecked because records can change or expire between the queries. Coordinator-owned terminal records take precedence over the page; the cap is not a newest-failure priority queue. - External REST-to-Prometheus exporter: remains available for existing releases, but this PR makes these metric data available natively without adding an exporter service or changing scheduling. Facts and constraints: this is additive telemetry on `dev`, not a backport to existing 2.3.13/3.0.0 binaries. Per-job collection defaults off. Slot values are heartbeat observations and cannot guarantee a future allocation or tag-specific failover admission. Terminal observations are bounded and are not a durable event log. Correct business recovery alerts depend on an explicit current-attempt mapping; its existence is an application responsibility, not something this implementation assumes or infers. Prometheus target labels/staleness still need normal failover handling. No connector registrations, existing configuration keys/defaults, job JSON/REST contracts, checkpoint/savepoint formats, scheduling behavior, or dependency/POM files are removed or changed. Verification performed: scoped Spotless apply/check passed for engine-common, engine-server and engine E2E base; staged diff whitespace check passed; independent full-diff/source review found no non-CI implementation blockers. No local compilation, tests, Docker, service startup, packaging, UI test or production validation ran. No build/deployment artifact was reused. `seatunnel-engine-ui` is unchanged and was excluded. Current-head GitHub CI is required; the tests below are added coverage, not claimed passing executions. Coverage/risk mapping: - `testTelemetryJobStatusOptIn`: detects missing YAML parsing or a changed default. - `testOperationalMetricsDoNotAccessUnreadyCoordinator` / `testOperationalMetricRegistrationDoesNotCollect`: detect startup/registration coordinator acquisition and disabled-mode history queries. - `testJobStatusMetricsBoundsTerminalHistory`: real Hazelcast paging of non-Comparable records, cutoff/future/null boundaries, truncation, immutable history, and the same window/cap for coordinator-owned terminal masters. - Extended `testPendingJobLifecycleInMasterFailover`: real split-cluster pending/running/canceled states, standby omission, restored-master export, slot invariant, and full slot release. - `testFailedSubmissionMetricsAndRecovery`: real failed execution and same-name resubmission preserve distinct IDs and aggregate semantics; controlled same-ID retained history cannot override live state or duplicate its metric. - Extended `MasterWorkerClusterSeaTunnelWithTelemetryIT`: real HTTP Prometheus and OpenMetrics status/name labels, and omission of finite-capacity metrics for dynamic workers. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
