tracelogging
tracelogging copied to clipboard
Feat: Add support for setting struct field size in tracelogging_dynamic for Rust
Description
When working with ETW events, I noticed we are missing the functionality to create a struct, and then populate it, and lastly, set it struct size. This workflow is typical in tracelogging_dynamic scenarios, where not all the data for the struct is known ahead of time. This facilitates a lot of workflows and code structure.
Example:
use tracelogging_dynamic as tld;
let mut field_count = 2;
let event = tld::EventBuilder::new();
// Create struct
event.add_struct("Struct", field_count, 0);
event.add_str8("string1", "value", tld::OutType::Default, 0);
event.add_str8("string2", "value", tld::OutType::Default, 0);
if let Some(value) = Some("hello, world".to_string()) {
event.add_str8("greeting",value, tld::OutType::Default, 0);
field_count = field_count + 1;
}
event.set_struct_field_count("Struct", field_count); // <-- Missing method
}
Other implementations
Other tracelogging implementation have this method: https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/3698be915322216aa126a67f19100b1cd93bb6c9/src/OpenTelemetry.Exporter.Geneva/External/TraceLoggingDynamic.cs#L1746
Feature Request:
Implement set_struct_field_count in EventBuilder struct for Rust in tracelogging_dynamic crate.