Skip to content

Higher precision start timestamp for Spans #2394

@adinauer

Description

@adinauer

Problem Statement

Spans are currently only ms precision but appear to be more precise due to being converted to a double. In the UI it looks like start_timestamp of a span is μs. This is caused by a number of things.

Solution Brainstorm

We could create a DateProvider interface which has a now() method that returns the current timestamp as SentryDate. Then there could by different implementations:

  • For older versions there could be one that keeps the current Date + System.nanoTime
  • For Java 9+ and Android API 26+ we could use Instant

We could then allow passing in SentryDate when starting a span or when calling finish. For users who want to supply their own timestamps with high precision we could offer something like a SentryDoubleDate that just holds a double.

The SentryDate should also have a Double diff(SentryDate date) method that can calculate the difference using internals like the separate System.nanoTime that was collected.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions