-
Notifications
You must be signed in to change notification settings - Fork 97
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
Change span ID to use random bytes #654
Conversation
src/span-data.ts
Outdated
@@ -14,6 +14,7 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
import {randomBytes} from 'crypto'; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@draffensperger FYI: I opened a PR to update CONTRIBUTING.md (#655) to write about running unit tests locally. What was the problem you encountered with initializing test fixtures? EDIT: For future readers -- the issue was that the last time |
Thanks for documenting that! As for my specific issue, I was getting an error like this:
It turns out that I still had some untracked directories in |
Codecov Report
@@ Coverage Diff @@
## master #654 +/- ##
==========================================
+ Coverage 96.06% 96.08% +0.01%
==========================================
Files 31 31
Lines 1627 1635 +8
Branches 293 295 +2
==========================================
+ Hits 1563 1571 +8
Misses 64 64
Continue to review full report at Codecov.
|
@@ -14,6 +14,7 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
import * as crypto from 'crypto'; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
test/test-trace-header-context.ts
Outdated
var receivedSpanId = receivedSpanIdAndOptions[0]; | ||
var receivedTraceOptions = receivedSpanIdAndOptions[1]; | ||
// Trace ID and trace options should be the same in sender and receiver. | ||
assert.equal(receivedTraceId, sentTraceId); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/span-data.ts
Outdated
() => randomFillSync(spanIdBuffer) : | ||
() => randomBytes(SPAN_ID_RANDOM_BYTES); | ||
// This evaluates to a large whole number such that any fractional number | ||
// between 0 and 1 multiplied by it will always give a whole number. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
859aa66
to
a422a57
Compare
src/span-data.ts
Outdated
|
||
function randomSpanId() { | ||
// No rounding is needed because SPAN_ID_MAX is bigger than 1 / Number.EPSILON | ||
return String(Math.random() * SPAN_ID_MAX); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'll merge this once CI passes
While running a test application that was composed of multiple Node.js apps, each with tracing enabled, we found that span IDs would conflict when the multiple apps were simultaneously started, because each started their span IDs at index 1. This switches to use secure randomness for span IDs to help ensure uniqueness even when multiple Node apps are started at the same time.