This repository was archived by the owner on Oct 3, 2023. It is now read-only.
hex span id serialization, more test cases #169
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What version of OpenCensus are you using?
What version of Go are you using?
go version go1.11.5 darwin/amd64
What did you do?
The span ID is a 64-bit id (confusing sidenote, the specs here claim it to be 8 bit). Both the Python (16-char hex encoded string) and Go (8-byte array) implementation generate this correctly.
However, there is an incompatibility in the propagation of traces. What the Python code does with the
GoogleCloudFormatPropagator
is put the span_id (which is a string type with hexadecimal chars) as string in the header. Then the header is something likeX-Cloud-Trace-Context: 129b452d2ef458f798c10811e2c28cf6/14a650d3b8b5ddde;o=1
Now the propagation code in Go expects an integer, as what the stackdriver exporter tries to do is parse that hexadecimal string as an integer with
This throws an error, leading the trace propagation to fail and traces being separated between services. Similarly, when creating a header for propagation in Go, it does put it in there as an integer number instead of the hexadecimal representation:
As a fix, I changed the (de)serialization to use hexadecimal representations. I also added some tests for different valid and invalid cases.
As a related but important note, which I'll raise in the Python repo as well: there's a difference in behaviour in parsing the headers. Python uses a regex which only matches exactly 16 characters as span id. The Go code doesn't use that regex (or any other), but works with splitting on separators and happily accepts a span id which is shorter than 16 characters. It will also propagate that shorter span ID further. The result is that the trace propagation fails between services in the different langauges. Should this behaviour be equalized between langauges?
Review by @rakyll and/or @Ramonza ?