Page MenuHomePhabricator

Including timing information in Metrics Platform events
Open, Needs TriagePublic

Description

We should including timing information in all events submitted by the Metrics Platform Client by default. This will allow Product Owners/Analysts to answer questions like the following without further intervention from a Software Engineer:

  • How long does it take for users to interact with an element?
  • How long does it take for an element to be seen?
  • How long does it take for the user to complete a workflow?

We could not calculate this from either the event.client_dt or event.meta.dt properties. The former is unreliable (see T259373: Develop strategy for mitigating degenerate client timestamps in event data). The latter is reliable but we would have to send at least one additional event per stream to determine an origin from which to measure.

All Grade A browsers support the High Resolution Time API (Performance.now()), which provides an high-ish-resolution timestamp "not subject to clock skew or adjustments" relative to Performance.timeOrigin.

Open Questions

1. Is there an equivalent API for Android and iOS?

Android: SystemClock.elapsedRealtime()
iOS: mach_continuous_time()

Acceptance Criteria

  • The time origin for each platform is chosen
    • JS: Performance.timeOrigin
  • The JS MPC includes timing information in submitted events
  • The PHP MPC includes timing information in submitted events
  • The Java MPC includes timing information in submitted events

Required

Event Timeline

phuedx updated the task description. (Show Details)
  1. Is there an equivalent API for Android and iOS?

@Dbrant: Is there an API similar to Performance.now() for Android?

phuedx updated the task description. (Show Details)

@Dbrant: Is there an API similar to Performance.now() for Android?

Yep, definitely: the most appropriate API to use for interval timing would be SystemClock.elapsedRealtime(), which gives absolute milliseconds since the device was booted, and includes time spent in deep sleep, etc.