open-telemetry / opentelemetry-specification

Specifications for OpenTelemetry
https://opentelemetry.io
Apache License 2.0
3.68k stars 883 forks source link

Set encoding rules for bytes represented in text and JSON #1252

Open rakyll opened 3 years ago

rakyll commented 3 years ago

What are you trying to achieve? When writing exporters, it's not clear how bytes should be represented in text or JSON output.

For example, trace ID (16 bytes), span ID (8 bytes) and trace flags can be represented as hex encoded strings.

andrewhsu commented 3 years ago

from the issue triage mtg today, discussed this. is this just about the traceid? if so, may already be specified in the spec (@mwear may know?)

if not, can you also suggest appropriate wording change?

chulkilee commented 3 years ago

Is it for OTLP/HTTP JSON? If so, doesn't Protocol Buffer 3 JSON Mapping define the encoding?

JSON value will be the data encoded as a string using standard base64 encoding with paddings. Either standard or URL-safe base64 encoding with/without paddings are accepted.

(We may use the same encoding for standard output)

anuraaga commented 3 years ago

For OTLP, we use hex instead of the standard proto mapping

https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/protocol/otlp.md#otlphttp-request

the trace_id and span_id byte arrays are represented as case-insensitive hex-encoded strings, they are not base64-encoded like it is defined in the standard JSON Mapping.

chulkilee commented 3 years ago

Oh, I missed that part 🤦

So the spec says hex (or base16) for OTLP/HTTP request with JSON encoded prototobuf message..

Reference: #786 and #911

Then what's this issue for? For text format? I'm wondering there is written spec for standard output - while the matrix has "Standard output" entry..