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

fix: Proposed fix for JSON ingestion issue #179

Merged
merged 2 commits into from
Mar 8, 2023
Merged

Conversation

kentquirk
Copy link
Contributor

Which problem is this PR solving?

OTLP/JSON data coming direct from browser sources is arriving with traceID and spanID encoded as hex, per spec.

But when this is fed through the OTLP protojson library that Husky uses, these values are being decoded as if they were encoded in base64.

The result is that Husky is corrupting these IDs.

Short description of the changes

  • This adjusts the BytesToTraceID function and adds bytesToSpanID to special-case the conversion (which we can detect by its length).

@kentquirk kentquirk requested a review from a team as a code owner March 7, 2023 23:50
@kentquirk kentquirk added the type: bug Something isn't working label Mar 7, 2023
Copy link
Contributor

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense as OTLP/JSON spec shows traceID & spanID will only be hex and not base64 encoded.

The changes make functional sense but think the bytesToTraceID and bytesToSpanID funcs could be refactored to be a little cleaner. I also think we should rename the new consts for hex only encoded trace and span IDs -- they aren't corrupted, just not base64 encoded.

otlp/traces.go Outdated Show resolved Hide resolved
otlp/traces.go Outdated Show resolved Hide resolved
Copy link
Contributor

@pkanal pkanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

Copy link

@fchikwekwe fchikwekwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good to me!

@kentquirk kentquirk merged commit 9c79e71 into main Mar 8, 2023
@kentquirk kentquirk deleted the kent.json_trace_id_fix branch March 8, 2023 16:11
kentquirk added a commit that referenced this pull request Mar 8, 2023
## Which problem is this PR solving?

- The bug fix in #179 had a bug, and it was found by a test in an
internal library before deploy.

## Short description of the changes

- Fix bug in BytesToTraceID
- Add a test that would have found the bug, and more test cases for the
new stuff

This requires a release to v0.22.1.
kentquirk added a commit that referenced this pull request Jan 3, 2024
## Which problem is this PR solving?

- In #179 we added some code to
deal with the fact that OTLP/JSON processing can't differentiate between
arrays of bytes that are encoded as hex and those that are encoded as
base64. When JS sends us browser-side telemetry, it encodes IDs as hex,
but when we receive it it's decoded as base64. This PR also applies that
to logs.

## Short description of the changes

- Adjust log's parentID so that it properly parses
- Add a new test case
- Move some code to common since it now applies across signals
- Move some tests to common
- Clarify some comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants