opentelemetry-js
opentelemetry-js copied to clipboard
feat: anchored clock
Introduce an anchored clock which is resistant to time drift. Create a single anchored clock instance per local trace and store the anchored clocks in a weak map on the tracer to ensure they don't memory leak.
Codecov Report
Merging #3134 (7f056da) into main (32cb123) will increase coverage by
0.00%
. The diff coverage is100.00%
.
Additional details and impacted files
@@ Coverage Diff @@
## main #3134 +/- ##
=======================================
Coverage 93.28% 93.28%
=======================================
Files 201 202 +1
Lines 6579 6599 +20
Branches 1379 1384 +5
=======================================
+ Hits 6137 6156 +19
- Misses 442 443 +1
Impacted Files | Coverage Δ | |
---|---|---|
...es/opentelemetry-core/src/common/anchored-clock.ts | 100.00% <100.00%> (ø) |
|
packages/opentelemetry-sdk-trace-base/src/Span.ts | 99.19% <100.00%> (+<0.01%) |
:arrow_up: |
...ackages/opentelemetry-sdk-trace-base/src/Tracer.ts | 98.68% <100.00%> (+0.22%) |
:arrow_up: |
...-trace-base/src/platform/node/RandomIdGenerator.ts | 87.50% <0.00%> (-6.25%) |
:arrow_down: |
Seems like browser tests are unhappy:
ERROR in ./test/common/anchored-clock.test.ts
Module not found: Error: Can't resolve 'perf_hooks' in '/__w/opentelemetry-js/opentelemetry-js/packages/opentelemetry-core/test/common'
@ ./test/common/anchored-clock.test.ts 19:21-42
Seems like browser tests are unhappy:
ERROR in ./test/common/anchored-clock.test.ts Module not found: Error: Can't resolve 'perf_hooks' in '/__w/opentelemetry-js/opentelemetry-js/packages/opentelemetry-core/test/common' @ ./test/common/anchored-clock.test.ts 19:21-42
and thats why we have them
i am getting these errors
Inconsistent start and end time, startTime > endTime [ 1663917517, 902433872 ] [ 1663917517, 901867218 ]
Hi @itai-codefresh, thanks for reporting this. Do you have a way to reproduce this issue? :thinking: If so, could you please open a bug ticket so that we can take a look? :slightly_smiling_face:
At least instrumentation express provides a timestamp to span.end()
but not to startSpan()
. Therefore two different time sources are used resulting in undefined results.
See https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1209 and https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1193