This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 formatting
- Loading branch information