ocaml-protoc
ocaml-protoc copied to clipboard
Overriding individual printers
I'm using this via ocaml-opentelemetry; but when dumping, this unhelpfully prints Bytes types as opaque blob:
send spans { scope_spans =
[{ scope =
...
spans =
[{ trace_id = <bytes len=16>;
span_id = <bytes len=8>;
trace_state = "";
parent_span_id = <bytes len=8>;
name = "alloc";
...
}
What's the least fragile way to replace the printer for spans..trace_id et al. with one that prints the ID as hexadecimal, instead of treating it as opaque? (Or, perhaps, that should perhaps be the default for short-ish Bytes?)
Sounds like a good idea. I'd say, by default, small bytes should be printed in hex, and large bytes should be like "deadbeef[...2415151 more bytes]". This should probably be configured at the level of the code generator (with an option to control if ellipsis occurs, and after how many bytes).