Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON parsing produces invalid trace and span IDs #106

Open
craigandrews opened this issue Mar 30, 2023 · 1 comment
Open

JSON parsing produces invalid trace and span IDs #106

craigandrews opened this issue Mar 30, 2023 · 1 comment

Comments

@craigandrews
Copy link

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.

@craigandrews
Copy link
Author

My workaround is to base64 encode the invalid IDs, then hex decode the result. This inverts the incorrect decoding and produces valid IDs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant