Skip to content

JSON parsing produces invalid trace and span IDs #106

@craigandrews

Description

@craigandrews

I am using RegisterTraceServiceHandlerFromEndpoint from go.opentelemetry.io/proto/otlp/collector/trace/v1 to allow forwarding of traces sent via HTTP to the gRPC endpoint. This works perfectly for Protobuf records, but produces invalid records when JSON is sent.

Expected behavior

Telemetry sent as JSON is parsed and converted to valid models.

Observed behaviour

Models produced by JSON input have trace and span IDs that are 50% longer than expected.

This appears to be because the code uses the default Protobuf JSON handler via the runtime.MarshalerForRequest function. This uses base64 to encode and decode binary arrays. This differs from the OTLP spec that states that trace and span IDs must be hex encoded.

The result is that the hex encoded IDs are being decoded as if they were base64.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions