open-telemetry / opentelemetry-swift

OpenTelemetry API for Swift
https://opentelemetry.io/docs/instrumentation/swift/
Apache License 2.0
207 stars 124 forks source link

trace and span IDs are base64-encoded when exporting OTLP JSON #537

Closed angelo-ebay closed 3 months ago

angelo-ebay commented 3 months ago

Hello, I am using OtlpTraceJsonExporter to export trace data as JSON and I am running in to an issue where the trace and span IDs are base64-encoded strings instead of being hex-encoded strings which is causing our collector endpoint to reject the payloads (e.g. OWUyYTNkYzA2MDc0YjE3NTQwZDU0ZGU0ZTUxZTczNWY= instead of 9e2a3dc06074b17540d54de4e51e735f).

According to this spec, the values should be hex-encoded.

The traceId and spanId byte arrays are represented as case-insensitive hex-encoded strings; they are not base64-encoded as is defined in the standard Protobuf JSON Mapping. Hex encoding is used for traceId and spanId fields in all OTLP Protobuf messages, e.g., the Span, Link, LogRecord, etc. messages. For example, the traceId field in a Span can be represented like this: { “traceId”: “5B8EFFF798038103D269B633813FC60C”, … }

Is this a known issue? The only workaround I'm able to find is decoding the JSON output of Message.jsonUTF8Data, decoding the base64 values, and re-encoding the JSON payload with the decoded trace/span IDs.