This repository was archived by the owner on Oct 3, 2023. It is now read-only.
Commit d8462a2
fix: Fix SpanId generation for interoperability (#126)
* Fix SpanId formatting for interoperability
SpanIds in opencensus-node are currently generated, sent in traces, and
propagated to other services as numeric values. This isn't consistent
with other opencensus libraries (e.g.:
[opencensus-java](https://github.com/census-instrumentation/opencensus-java/blob/master/api/src/main/java/io/opencensus/trace/SpanId.java)
serializes the span id as lowercase base16). When opencensus-node is
setup with B3 propagation, this SpanId format violates the [B3
specification](https://github.com/openzipkin/b3-propagation#spanid-1)
which mandates lowercase base16 encoding. Generally speaking,
opencensus-java only accepts spans in this format so it will fail to
correctly link to any span generated by opencensus-node. The best case
scenario is a shared trace id with a missing parent span link.
This PR removes the integer parsing, and leaves it as lowercase hex
characters. I tested locally with B3 propagation where node creates the
root span and propagates it to a Java service instrumented with
opencensus-java, and verified the data is correctly ingested and
correlated in Jaeger.
* Convert spanId into a numeric value for stackdriver
Using the hex2dec library also used by
https://github.com/googleapis/cloud-trace-nodejs/ , so assuming this
dependency is okay.
* Fix formatting1 parent 62e3a6c commit d8462a2
File tree
8 files changed
+1520
-972
lines changed- packages
- opencensus-core/src/internal
- opencensus-propagation-b3/src
- opencensus-propagation-jaeger/src
- opencensus-propagation-stackdriver
- src
- test
8 files changed
+1520
-972
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
| 79 | + | |
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
| 100 | + | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| |||
0 commit comments