Skip to content

Resource and navigation timing event timestamps should use the entry's start time #496

Closed

Description

@martinkuba

The resource timing and navigation timing instrumentations emit their events without setting timestamp (resource timing, navigation timing). The SDK then defaults the timestamp to emission time (LogRecordImpl.ts).

For resource timing, entries are queued and processed in an idle callback, so the timestamp can be well after the resource loaded. The semconv requires performance.timeOrigin + entry.startTime (events.yaml). Raised in open-telemetry/semantic-conventions-client-side#14 (comment).

For navigation timing, the event is emitted after load (with retries until the entry is complete), so it's stamped at emit time rather than at the start of the navigation. The semconv doesn't specify a timestamp for this event yet, but using the entry's startTime (always 0, i.e. timeOrigin) would be consistent with resource timing.

Fix: set timestamp: entry.startTime in both instrumentations. The SDK converts it to an absolute time, the same way the web-vitals instrumentation already does.

Tests should use a nonzero startTime for resource timing and assert the exported timestamp equals timeOrigin + startTime when:

  • the idle callback runs after the clock has advanced
  • visibilitychange flushes the queue before the callback runs
  • disable() flushes the queue before the callback runs

For navigation timing, assert the exported timestamp equals timeOrigin when the event is emitted after a delay or after retries.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    availablebuginstrumentation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions