-
Notifications
You must be signed in to change notification settings - Fork 821
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
use Date.now() for instrument recording timestamps #3514
use Date.now() for instrument recording timestamps #3514
Conversation
21e3359
to
d1693ac
Compare
04dfb20
to
bf88a07
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3514 +/- ##
==========================================
+ Coverage 93.03% 93.79% +0.75%
==========================================
Files 242 249 +7
Lines 7167 7640 +473
Branches 1502 1589 +87
==========================================
+ Hits 6668 7166 +498
+ Misses 499 474 -25
|
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.
Thank you for working on this!
I find 2 additional call sites of hrTime
in the sdk-metrics that can be replaced:
- https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/sdk-metrics/src/aggregator/LastValue.ts#L40
- https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/sdk-metrics/src/state/MetricCollector.ts#L39
Would you mind updating these call sites too?
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.
Whoops, may have miscommunicated - no need to even update the version, all versions are updated automatically via lerna
when we create a new release. 🙂
Leaving versions as-is is fine 🙂
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.
Looks good, thank you for contributing 🙂
…/opentelemetry-js into fix_metric_timestamp_drift
…/opentelemetry-js into fix_metric_timestamp_drift
…/opentelemetry-js into fix_metric_timestamp_drift
Which problem is this PR solving?
Fixes metric timestamps in the distant past in the browser, related to timestamp drift described extensively in #3279. However, the fix is much simpler here than in the tracing case -- as per this comment, we have no need for monotonicity here and can safely just use
Date.now()
Fixes #3383
Short description of the changes
changes the implementation of
SyncInstrument._record
to usetimeInputToHrTime(Date.now())
instead ofhrTime()
. The latter uses the performance API, which is overkill in this situation (we don't need monotonicity) and is often way behind real time on many browsers.This comment indicates that we should wait for consensus here, as we might instead introduce some sort of global clock API. I don't object to waiting, but it seems to me that we should fix the bug before the (probably lengthy) debate/implementation of a clock API. The default clock is broken in the browser context, and that should take priority over nontraditional runtimes that can't use
Date
. But I don't mind being overruled here; it's not like this fix took me very long to implement.Type of change