Commit 14d57ae
fix(freshness): send freshness diagnostics in milliseconds with measure=time (#2770)
V4 (contract-scan) freshness checks rendered in Soda Cloud check charts as
raw, unitless floats (e.g. "11.15...") instead of a human-readable duration.
The diagnostics payload was wrong in two ways:
1. measure missing: diagnostics never set a `measure` key, so Soda Cloud and
the frontend formatted the value as a plain number rather than a duration.
2. wrong unit: `value` (and the `fail` threshold bounds) were emitted in the
check's configured unit (fractional hours/days) instead of milliseconds.
The frontend formats a "time" measure by dividing the wire value by 1000 and
rendering it as "X days and Y hours", so it relies on the value being in
milliseconds and tagged with `measure="time"` — exactly the V3 (SodaCL) wire
contract, where freshness sends round(total_seconds * 1000) ms + measure="time".
This adds two opt-in hooks on the base CheckResult — `get_soda_cloud_measure()`
(default None) and `to_soda_cloud_measure_value()` (identity) — overridden by
the freshness result to return "time" and scale the configured-unit value to
milliseconds. The diagnostics builder routes the value and fail bounds through
the converter and only emits a `measure` key when non-None, so payloads for all
non-time check types are byte-for-byte unchanged. The unit scale lookup falls
back to the default ("hour") for a missing/unknown unit so it can never KeyError
mid-upload and abort the whole scan's result upload.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent d605511 commit 14d57ae
5 files changed
Lines changed: 135 additions & 7 deletions
File tree
- soda-core/src/soda_core
- common
- contracts
- impl/check_types
- soda-tests/tests
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1774 | 1774 | | |
1775 | 1775 | | |
1776 | 1776 | | |
1777 | | - | |
| 1777 | + | |
1778 | 1778 | | |
1779 | | - | |
| 1779 | + | |
1780 | 1780 | | |
1781 | | - | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
1782 | 1787 | | |
1783 | 1788 | | |
1784 | 1789 | | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
1785 | 1796 | | |
1786 | 1797 | | |
1787 | 1798 | | |
| |||
1900 | 1911 | | |
1901 | 1912 | | |
1902 | 1913 | | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
1903 | 1918 | | |
1904 | | - | |
1905 | | - | |
1906 | | - | |
1907 | | - | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
1908 | 1923 | | |
1909 | 1924 | | |
1910 | 1925 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
406 | 424 | | |
407 | 425 | | |
408 | 426 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
308 | 331 | | |
309 | 332 | | |
310 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
769 | 769 | | |
770 | 770 | | |
771 | 771 | | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
772 | 837 | | |
773 | 838 | | |
774 | 839 | | |
| |||
0 commit comments