fix: encode OTLP trace identifiers as hex - #54
Conversation
|
|
d801061 to
a62f851
Compare
|
I would prefer to wait for Arwalk/zig-protobuf#176 to do it cleanly |
inge4pres
left a comment
There was a problem hiding this comment.
Thanks for sending this PR @incidere 🙏🏼
I agree with @agagniere that the proposed approach, while functionally working, can be better addressed at a lower level in the protobuf JSON decoder (real fix is in Jacob's PR Arwalk/zig-protobuf#176).
I liked that you added tests, would love to see them added also for LogRecord (and also Exemplars once implemented), but only after we have bumped our zig-protobuf depedency.
| return next; | ||
| } | ||
|
|
||
| fn encodeOtlpIdsAsHex(json: []const u8, allocator: std.mem.Allocator) ![]u8 { |
There was a problem hiding this comment.
Zig 0.16.0 has a std.Io.Writer.printHex function that converts to Hex digits for us
https://ziglang.org/documentation/0.16.0/std/#std.Io.Writer.printHex
Fixes #50.
OTLP's JSON mapping represents trace and span identifiers as hexadecimal strings instead of protobuf's default base64.
This change:
traceId,spanId, andparentSpanIdafter protobuf JSON encoding;Span,Link, a parent span, and an unrelated bytes attribute.Tests:
zig build sdk-test -Dtarget=x86_64-linux-musl— 290 tests passedzig fmt --check opentelemetry-sdk/src/otlp.zig