tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.15k stars 673 forks source link

tracing: allow `&[u8]` to be recorded as event/span field #2954

Closed mladedav closed 2 months ago

mladedav commented 2 months ago

Motivation

Users may want to pass data to Subscribes which is not valid UTF-8. Currently, it would have to be encoded into &str to be passed as a field value.

Solution

This branch adds a record_byte_slice method to Visit. It has an implementation falling back to record_debug so it is not be a breaking change.

JsonVisitor got an overridden implementation as it should not use Debug output and encode it as a string, but rather store the bytes as an array.

PrettyVisitor go an overridden implementation to make the output more pretty.

hawkw commented 2 months ago

okay, i've enabled auto merge so this should merge once CI passes — let's merge master to pick up the Clippy fixes?