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

SentryNanotimeDate.nanoTimestamp does not provide nanosecond precision #3210

Closed
markushi opened this issue Feb 16, 2024 · 3 comments
Closed

Comments

@markushi
Copy link
Member

Description

Came up when working on frame delay:

/**
* Because {@link SentryNanotimeDate#nanoTimestamp()} only gives you millisecond precision, but
* diff doesn't in case of {@link SentryNanotimeDate} ¯\_(ツ)_/¯
*
* @param date the input date
* @return a timestamp in nano precision
*/
private static long realNanos(final @NotNull SentryDate date) {
return date.diff(UNIX_START_DATE);
}

@adinauer
Copy link
Member

@markushi this is a limitation on older Java SDKs and Android. If you have access to a better time source, you can provide a different SentryDate, e.g. SentryLongDate.

@markushi
Copy link
Member Author

Let's close this one for now, as https://developer.android.com/reference/java/lang/System#nanoTime() doesn't really provide a date instance, but rather an arbitrary origin time, which is not useful for e.g. spans per se.

@github-project-automation github-project-automation bot moved this from Needs Discussion to Done in Mobile & Cross Platform SDK Feb 28, 2024
@romtsn
Copy link
Member

romtsn commented Feb 28, 2024

here's Alexes research #2451 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants