fix(ludic.telemetry): nothing made per event - properties and the line written into kept buffers, the queue a ring of bytes made at the start
An event was a tree of values encoded into a new string, a dropped line was never given back, and every batch and save joined the queue into another. Now: telemetry_props / telemetry_str / _int / _bool write the properties as JSON into a buffer the state keeps; the line is written beside it, its time worked out from the clock's seconds (TelemetryWorld.clock_s, was stamp); its bytes go into one ring (ring_bytes, at most queue_max lines), the oldest overwritten past either; a batch and the file are written into a third kept buffer and go as bytes (TelemetryTransport.send takes the bytes and their length; Http.body_bytes, Fs.write_bytes). The facts are pooled. tests/ring_test: ten thousand events past the cap in lines and in bytes, 0 bytes of heap; the line exact JSON, escaped, 2000-02-29 right; the batch puts the id in; the file round-trips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fc0f3d3790
commit
d1bea7f10e
14 changed files with 454 additions and 97 deletions
|
|
@ -18,18 +18,18 @@ program TelemetryTest {
|
|||
function fake_now(telemetry_test_st: TelemetryTestState) -> int { return telemetry_test_st.clock }
|
||||
function fake_enabled(telemetry_test_st: TelemetryTestState) -> bool { return telemetry_test_st.on }
|
||||
function fake_can(telemetry_test_st: TelemetryTestState) -> bool { return telemetry_test_st.allowed }
|
||||
function fake_stamp() -> string { return "2026-09-25T12:00:00Z" }
|
||||
function fake_send(telemetry_test_st: mut TelemetryTestState, url: string, body: string) -> int {
|
||||
function fake_clock() -> int { return 1790337600 }
|
||||
function fake_send(telemetry_test_st: mut TelemetryTestState, url: string, body: []byte, n: int) -> int {
|
||||
if telemetry_test_st.refuse { return -1 }
|
||||
telemetry_test_st.sends += 1
|
||||
telemetry_test_st.last_url = url
|
||||
telemetry_test_st.last_body = body
|
||||
telemetry_test_st.last_body = text_of(body, n)
|
||||
return 7
|
||||
}
|
||||
function fake_poll(telemetry_test_st: TelemetryTestState, h: int) -> int { return telemetry_test_st.answer }
|
||||
function fake_drop(h: int) -> void { }
|
||||
|
||||
bind TelemetryWorld { can_send: fn fake_can, enabled: fn fake_enabled, now_ms: fn fake_now, stamp: fn fake_stamp }
|
||||
bind TelemetryWorld { can_send: fn fake_can, enabled: fn fake_enabled, now_ms: fn fake_now, clock_s: fn fake_clock }
|
||||
bind TelemetryTransport { send: fn fake_send, poll: fn fake_poll, drop: fn fake_drop }
|
||||
|
||||
function qfile() -> string { return Os.temp_dir() + "/ludic-telemetry-test-queue.txt" }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue