Add configurable KVP client API and harden concurrent telemetry writes#286
Open
peytonr18 wants to merge 3 commits intoAzure:mainfrom
Open
Add configurable KVP client API and harden concurrent telemetry writes#286peytonr18 wants to merge 3 commits intoAzure:mainfrom
peytonr18 wants to merge 3 commits intoAzure:mainfrom
Conversation
cadejacobson
approved these changes
Feb 20, 2026
Contributor
cadejacobson
left a comment
There was a problem hiding this comment.
This looks awesome to me! Good work
cjp256
reviewed
Feb 20, 2026
Increase thread/process write volume to better stress lock safety, and route KVP file opening through Kvp initialization with a private helper to keep open behavior consistent and constrained.
anhvoms
reviewed
Feb 23, 2026
libazureinit/src/kvp.rs
Outdated
| // that two concurrent callers cannot both decide the file is stale and | ||
| // truncate data the other has already written. | ||
| FileExt::lock_exclusive(&file).map_err(|e| { | ||
| anyhow::Error::from(e).context("Failed to lock KVP file for truncation") |
Contributor
There was a problem hiding this comment.
if this is expected (that only one client is expected to do the truncation), this should not be an error. We can easily conclude an error situation by seeing all clients failing, but no successful truncation (from the log a few lines below)
5528da4 to
d537d8a
Compare
d537d8a to
c28024a
Compare
anhvoms
reviewed
Mar 4, 2026
| .file_path("/var/lib/hyperv/.kvp_pool_1") | ||
| .truncate_on_start(true), | ||
| )?; | ||
| custom.emit("Custom event payload", None)?; |
Contributor
There was a problem hiding this comment.
I think we want to document that KVPs emitted after health report (emit_health_report) are not collected by Azure platform today.
It might be helpful to show a bit more complicated example like emit an in-progress provisioning, call a function foo, then emit a report failure on foo's failure; otherwise emit a success
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expands KVP telemetry beyond the original event-prefix change by introducing a public, external-caller-friendly KVP client API, while strengthening concurrency behavior for startup truncation and documenting the end-to-end design.
This enables multiple emitters/libraries to coexist more safely and gives callers explicit control over KVP emission lifecycle and identity.
Changes
New public KVP client API (
kvp.rs, re-exported vialogging.rs)KvpOptionswith builder-style configuration:vm_idevent_prefixfile_pathtruncate_on_startKvp::new()(default options path).Kvp::with_options(...)for explicit caller configuration.emit(message, level)emit_health_report(report)close().awaitfor graceful shutdown and queue drain.Internal wiring updates (
logging.rs)setup_layerscontinues to use tracing-layer emission internally.Kvp::new_internal(...)with explicit options-derived inputs.Concurrency hardening for startup truncation (
kvp.rs)Breaking Changes
This PR intentionally changes the public KVP API shape:
Kvp<S>::new(...), .layer(), .halt()).Kvp::new/with_options,emit,emit_health_report,close).Goal
tracing_subscriberplumbing.Resolves #239