Skip to content

Fix millisecond precision in evaluation serverTime - #48

Open
paullianyang wants to merge 1 commit into
statsig-io:mainfrom
paullianyang:codex/preserve-server-time-milliseconds
Open

paullianyang wants to merge 1 commit into
statsig-io:mainfrom
paullianyang:codex/preserve-server-time-milliseconds

Conversation

@paullianyang

Copy link
Copy Markdown

Summary

Preserve millisecond precision in EvaluationDetails#server_time while keeping its string representation.

The current expression converts Time.now to integer seconds before multiplying by 1,000, so every value ends in 000. Convert to milliseconds before truncating instead, matching the timestamp-construction pattern already used by StatsigEvent.

For example, a time of 1631638014.811999 seconds currently produces "1631638014000"; this change produces "1631638014811".

This changes evaluation metadata (serverTime) only. It does not change the top-level event time, batching, deduplication, or export behavior, and does not claim to fix downstream exposure/event ordering.

Tests

  • Added a deterministic regression test with whole-second, fractional-second, and end-of-second cases; exact string expectations also preserve the existing type contract.
  • Confirmed the regression fails before the fix and passes afterward: ruby -Ilib test/evaluation_details_precision_test.rb (1 test, 3 assertions).
  • Ruby syntax checks and git diff --check pass.
  • Tested locally with Ruby 2.6.10. The full SDK suite was not run: bundle check reports missing dependencies.

@paullianyang

Copy link
Copy Markdown
Author

for context the rounding is causing near exposure time metrics to show up prior to exposure rather than after.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant