Skip to content

feat(kvp): add diagnostics layer over KvpPoolStore#313

Open
peytonr18 wants to merge 1 commit into
Azure:mainfrom
peytonr18:probertson-diganostics-kvp
Open

feat(kvp): add diagnostics layer over KvpPoolStore#313
peytonr18 wants to merge 1 commit into
Azure:mainfrom
peytonr18:probertson-diganostics-kvp

Conversation

@peytonr18

@peytonr18 peytonr18 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds a DiagnosticsKvp layer that centralizes azure-init's KVP telemetry behavior, including event key formatting, message chunking, and message reassembly. This provides a single tested implementation that can be reused by the follow-up wiring PR and simplifies the existing logic in kvp.rs and logging.rs.

It also adds diag CLI commands for decoding and viewing KVP telemetry as readable events, making provisioning diagnostics easier to inspect and troubleshoot.

Specifically, this PR adds:

  • DiagnosticsKvp, a typed view over KvpPoolStore that implements telemetry-specific behavior while keeping the underlying store format-agnostic:

    • Event keys formatted and parsed as <prefix>|<vm_id>|<level>|<name>|<event_id>.
    • Message chunking at UTF-8 boundaries for values larger than a single KVP record, written via append_multiple and reassembled when read.
    • Classification of records as diagnostic events, raw records such as PROVISIONING_REPORT, or malformed event keys.
  • New diag CLI commands (dump, events, tail, clear) that operate on decoded and reassembled telemetry data, separate from the existing raw KVP commands.

Example

A long event is stored as multiple records sharing one key. The raw view shows the fragments; diag decodes and reassembles them into a single event:

$ azure-init-kvp dump
azure-init-1.0.0|3f25…|INFO|user:create_user|8f3e…=Time: … | Event: creating
azure-init-1.0.0|3f25…|INFO|user:create_user|8f3e…= azureuser (uid 1000) …

$ azure-init-kvp diag events
event level=INFO name=user:create_user event_id=8f3e… message=Time: … | Event: creating azureuser (uid 1000) …

$ azure-init-kvp diag dump --json
{"chunks":2,"event_id":"8f3e…","kind":"event","level":"INFO","message":"…","name":"user:create_user"}
{"kind":"raw","key":"PROVISIONING_REPORT","value":"result=success|…"}

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.92%. Comparing base (3310a88) to head (603d113).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #313      +/-   ##
==========================================
+ Coverage   95.70%   95.92%   +0.22%     
==========================================
  Files          23       24       +1     
  Lines        7705     8127     +422     
==========================================
+ Hits         7374     7796     +422     
  Misses        331      331              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants