Repository navigation
Description
Purpose
Provide a machine-readable JSON execution report so agents, CI jobs, and other callers can determine execution outcome, inspect failures, and assess work performed without parsing console logs.
Report interface
- Add an opt-in CLI option to write a report to a specified file. Final option naming is to be decided during implementation.
- Expose equivalent report data to embedded Java callers, reusing existing execution statistics where possible.
- Include a schema version, Scriptella version, execution identifier, outcome (
success,failed, orcancelled), UTC start/end timestamps, and elapsed duration measured with a monotonic clock. - Produce reports for success, handled failures, and cooperative cancellation, including validation/setup failures where feasible. A hard process termination cannot guarantee a report.
- Keep reports separate from console output. Preserve existing execution exit statuses; report-writing failure must be visible and must not mask the original execution error. Define the exit behavior when execution succeeds but the requested report cannot be written.
- Publish the report atomically where supported so consumers do not mistake a partially written file for a completed report.
Metrics
Extend existing statistics with lightweight counters collected during normal execution. Include totals and, where meaningful, aggregates per ETL element/location and connection ID:
- Successful and failed element execution counts.
- Executed statement counts.
- Query rows emitted to nested ETL elements (not an estimate of rows scanned by the source).
- Affected-row counts reported by drivers, including batches flushed during finalization.
- Batch execution counts and submitted batch entries where supported.
- Element elapsed working time, with documented inclusive/exclusive semantics; nested durations must not be summed as total wall time.
- Query-row and statement throughput derived from clearly defined counters and durations.
- Observed warning counts, without retaining unbounded warning details.
- Connection open/close counts and elapsed connection-initialization time where observable, to help identify repeated connection setup costs.
Define each metric precisely. Use null or an explicit availability indicator for unsupported/unknown measurements rather than reporting a misleading zero. JDBC unknown batch update counts must remain distinguishable from known affected-row counts. Report partial counts on failure and cancellation, and indicate completeness. Affected rows describe driver-reported work, not guaranteed committed rows; make transaction outcome explicit where known.
Error information
- Provide a bounded structured error with category, ETL location, exception type, sanitized message, and SQLState/vendor error code where available.
- Distinguish terminal failures from element failures handled by ETL error-handling rules.
- Exclude credentials, connection URLs, SQL/script text, bound values, and input records by default. Driver messages may contain sensitive values and require sanitization; omit unsafe details where reliable sanitization is not possible.
- Stack traces are outside the default report.
Acceptance criteria
- Document the JSON schema, field units, metric semantics, availability, and compatibility policy.
- Include examples for successful execution, partial failure, and cancellation.
- Verify counter accuracy for nested queries, repeated scripts, batching/final partial batches, rollback, and handled errors.
- Verify report behavior for setup errors, report-write failures, and unsupported driver statistics.
- Keep memory bounded by ETL structure/connections, not row count; avoid per-row events and expensive profiling or resource sampling in this MVP.
Related: #18 (elapsed time on failure). This reporting feature is independent of the JSON data driver in #72.
Activity
ejboy commentedon Oct 21, 2026
Quick implementation analysis: inexpensive metrics
Source inspection of the current checkout suggests the following priority. These are implementation estimates, not measured overhead results; no code changes or tests were made.
1. Reuse existing statistics first
ExecutionStatisticsBuilderand exposed throughExecutionStatistics.ElementInfo. Working time excludes nested element execution time; retain and document that meaning. Failed-element counts are not necessarily independent errors: one failure can propagate through nested elements.JdbcConnection.addUpdateCount,ConnectionManager.getUpdateCount, andExecutionStatistics.getUpdateCount, including successful final batch flushes. This currently sums positive counts; it is not a committed-row count or a complete result for drivers returning unknown counts.2. Cheap additions worth including in the MVP
QueryExecutor.QueryCtxDecorator.processRow()is a common hook across drivers and already increments a row number. Add persistent long counters there (the current row number is an int local to one invocation). Count before nested execution so a row whose child fails still counts as emitted. Optionally count rows whose child processing completed separately. Preserve partial counts on exceptions; aggregating only after successfulexecuteQuery()would lose them. Summing nested-query rows counts emissions at each level, not unique input records.driver.connect()sites inConnectionManager.getConnection()andnewConnection(). Use monotonic timing in a finally block and retain aggregates before manager cleanup. This covers normal, lazy, and new-transaction connections without per-row timers.SqlExecutor. Distinguish unsupported/no-op operations from actual JDBC calls. These describe observed calls, not a global transaction guarantee. This is especially useful when a failed execution has already committed earlier work.3. Useful, but need explicit bookkeeping
StatementWrapperbatch execution, retaining batch size before its finally block resets it. This must include flushes caused by batch thresholds, queries, final commit, and cache lifecycle.StatementWrapper.executeBatch()currently sums positive results and discards JDBCSUCCESS_NO_INFO/EXECUTE_FAILED. Preserve separate counters and inspectBatchUpdateException.getUpdateCounts()for partial results. Do not infer exact affected rows from submitted entries. Per-connection aggregation is easier than correct per-element attribution when cached batches flush later; defer per-element batch attribution if necessary.SqlExecutor.logExecutedStatement()already obtains connection warnings, so no extra JDBC polling is necessary. However, traversal/clearing currently depends on the logging path. Count independently of log level, define warning-chain clearing semantics, and avoid counting the same retained warning repeatedly. Call the metric observed JDBC warnings, not all application warnings.Suggested first implementation
Start with existing statistics, monotonic run duration, query-row emissions, connection initialization/close metrics, and observed JDBC transaction operations. Add batch outcome counters next; include warning counts only with correct lifecycle handling. Keep aggregates bounded by ETL locations/connections, using primitive counters and timers around operations rather than per-row event objects.
Defer CPU/heap/GC attribution, process-wide log interception, byte counts across all drivers, database/server metrics, and committed-row estimates. These require broader instrumentation or would be misleading for embedded execution. Per-connection totals should survive cleanup, and unavailable statistics should remain explicitly unknown.
Add JSON execution reports and metrics (#73)
ejboy commentedon Nov 3, 2026
For 1.7.0, the implemented JSON execution report MVP in 05fd6ad is accepted: success, failure and cancellation reports with the documented available metrics. Batch, transaction, throughput, warning and other advanced metrics in this issue are deferred and are not implemented in 1.7.0. Keep this issue open for the remaining work, outside the 1.7.0 milestone; no later release is committed.
ejboy commentedon Nov 3, 2026
Closing as completed for the accepted 1.7.0 JSON execution-report MVP, which has been released and validated. The report covers success, failure and cooperative cancellation, the documented available metrics, partial results and sanitized errors.
The original issue also described potential advanced metrics. Batch outcomes and timings, transaction telemetry, warning counts, provider-specific metrics, derived throughput and separate handled-error counters are not implemented in 1.7.0. They are deferred ideas, not commitments for a future release; if pursued, they should be scoped and tracked separately. The maintainer's private execution-report notes preserve the design context.