Skip to content

Emit "time" measure and millisecond values for freshness check diagnostics#2760

Open
m1n0 wants to merge 1 commit into
mainfrom
SAS-12728-freshness-check-time-measure
Open

Emit "time" measure and millisecond values for freshness check diagnostics#2760
m1n0 wants to merge 1 commit into
mainfrom
SAS-12728-freshness-check-time-measure

Conversation

@m1n0

@m1n0 m1n0 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Problem

V4 contract-scan freshness checks render as raw floats (e.g. 11.155277…) in Soda Cloud's check charts instead of a human-readable duration — V3 showed clean unit-bearing values like "X days and Y hours". Two gaps in the freshness diagnostics soda-core sends:

  1. No measure/type marker on the value, so Soda Cloud formats it as a plain number.
  2. The value is in the check's configured unit (hours/days), but the duration formatter expects milliseconds.

Fix

Align the freshness diagnostics wire payload with the proven V3 soda-library FreshnessCheck contract:

  • emit diagnostics.measure = "time" so the value is formatted as a duration
  • express diagnostics.value and the fail threshold bounds in milliseconds (scaled from the configured unit)

Implemented via two hooks on CheckResult:

  • get_soda_cloud_measure()None by default, "time" for freshness
  • to_soda_cloud_measure_value() — identity by default, unit → ms for freshness

Both default to no-ops, so non-time check payloads are byte-for-byte unchanged.

Tests (written test-first, red → green)

  • Unit (test_soda_cloud.py): freshness diagnostics carry measure == "time" and value 3_600_000 ms; non-time checks omit measure.
  • Integration (test_freshness_check.py): end-to-end upload payload asserts measure, value in ms, and fail.greaterThanOrEqual in ms.
  • Regression: missing / duplicate / row-count diagnostics unchanged.

Formatted with black 23.3.0 (repo-pinned).

Notes

  • Freshness is floored to whole-second precision (freshness_in_seconds) before scaling to ms; V3 kept sub-second precision. Negligible for freshness.
  • V3 also emitted a warn threshold in ms; V4's diagnostics builder has no warn block today — out of scope here.

🤖 Generated with Claude Code

V4 contract-scan freshness checks sent their value in the configured unit
(hours/days) with no measure marker, so Soda Cloud rendered a raw float
instead of a human-readable duration. Align the freshness wire payload with
the V3 soda-library contract: emit diagnostics.measure = "time" and express
the value plus fail thresholds in milliseconds.

- Add CheckResult.get_soda_cloud_measure() / to_soda_cloud_measure_value()
  hooks (identity by default, so non-time check payloads are unchanged).
- FreshnessCheckResult returns "time" and scales its configured unit to ms.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant