getsentry / getsentry/sentry-cocoa

Use absolute time for tracing duration

Open
#2,155 5 comments 0 reactions 0 assignees View on GitHub
Cocoa Improvement Spans
Dominant language
Swift
Stars
1.1k
Forks
418
Avg merge
2d 3h
Merged PRs (30d)
106

Description

### Description

Currently, our transactions and spans use NSDate, which is not a safe API for time-sensitive measurements because
the time can be changed in iOS settings or by the system when it recalibrates with a remote
source of truth. Instead, we could switch to absolute system timestamps as used by profiling.
[https://github.com/getsentry/sentry-cocoa/blob/eefdeedf0d7edd17ac03e89ab7a4da75f24bc1ff/Sources/Sentry/include/SentryTime.h#L10-L14]()

We could achieve this by internally keeping track of absolute timestamps and converting these to NSDate when finishing a transaction. We might also have to adjust span timestamps, as the system time could have changed during the lifetime of a transaction.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.