Skip to content
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

PPI-165 : fix timestamp rounding issues and expose helpers for high res timestamps #179

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

blakeroberts-wk
Copy link
Contributor

@blakeroberts-wk blakeroberts-wk commented Jul 29, 2024

Which problem is this PR solving?

WebTimeProvider suffers from rounding issues when using window.performance.timeOrigin:

raw (ms) 1722292170313.4
cur (ns) 1722292170313399800

The output above comes from the following script:

// import 'dart:html';

const int _nanosecondsPerMillisecond = 1000 * 1000;

void main() {
  final raw = 1722292170313.4;
  print('raw (ms) $raw');

  final cur = (raw * _nanosecondsPerMillisecond).round();
  print('cur (ns) ${cur}');

//   final raw = window.performance.timeOrigin ??
//       window.performance.timing.navigationStart;
//   final cur = (raw * _nanosecondsPerMillisecond).round();
//   print('raw now (ms) ${raw}');
//   print('cur now (ns) ${cur}');
}

Short description of the change

Update conversion from doubles representing milliseconds to int64s representing nanoseconds.

Additionally, experimental helper methods have been exposed from the web_sdk package to assist with using timestamps from the performance API as timestamps in OpenTelemetry (span start time, end time, span event timestamps).

How Has This Been Tested?

Used dart pad, unit tests, and an example app which created spans from performance entry timestamps.

Checklist:

  • Unit tests have been added
  • Documentation has been updated

@aviary3-wk
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

@blakeroberts-wk blakeroberts-wk force-pushed the ppi-165-fix-timestamps branch from dd6a5f6 to ee26a2b Compare July 30, 2024 15:57
@blakeroberts-wk blakeroberts-wk changed the title partially fix timestamp rounding issues fix timestamp rounding issues and expose helpers for high res timestamps Jul 30, 2024
@blakeroberts-wk blakeroberts-wk changed the title fix timestamp rounding issues and expose helpers for high res timestamps PPI-165 : fix timestamp rounding issues and expose helpers for high res timestamps Jul 31, 2024
@blakeroberts-wk blakeroberts-wk marked this pull request as ready for review July 31, 2024 21:13
@blakeroberts-wk
Copy link
Contributor Author

QA +1 unit tests and dart pad produce expected output. additional manual verification was used within a browser app where spans were created using timeOrigin as well as timestamps from performance events/marks

@blakeroberts-wk
Copy link
Contributor Author

@Workiva/release-management-p

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from RM

@rmconsole6-wk rmconsole6-wk merged commit 3e77363 into master Aug 1, 2024
4 checks passed
@rmconsole6-wk rmconsole6-wk deleted the ppi-165-fix-timestamps branch August 1, 2024 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants