Skip to content

fix(metricscollector): parse fractional UNIX timestamps in JSON logs#2672

Open
immanuwell wants to merge 1 commit into
kubeflow:masterfrom
immanuwell:fix/json-metrics-timestamp-parsing
Open

fix(metricscollector): parse fractional UNIX timestamps in JSON logs#2672
immanuwell wants to merge 1 commit into
kubeflow:masterfrom
immanuwell:fix/json-metrics-timestamp-parsing

Conversation

@immanuwell

Copy link
Copy Markdown

What this PR does / why we need it

file-metricscollector supports JSON logs, but numeric UNIX timestamps with fractions were parsed wrong. The fractional part was treated like raw nanoseconds, so 1638422847.28721 became 2021-12-02T05:27:27.000028721Z instead of 2021-12-02T05:27:27.28721Z.

This patch keeps the fractional seconds when building the RFC3339 timestamp. String timestamps and integer UNIX timestamps stay the same. This is a small fix, but it is pretty easy to hit on the JSON log path.

Related to #944
Follow-up to #1765

How to reproduce

  1. Run go test ./pkg/metricscollector/v1beta1/file-metricscollector -count=1
  2. Before this patch, the JSON fixture in TestCollectObservationLog stored 1638422847.28721 as 2021-12-02T05:27:27.000028721Z
  3. With this patch, it stores 2021-12-02T05:27:27.28721Z

Checklist:

  • Docs included if any changes are user facing

@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign gaocegege for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown

🎉 Welcome to the Kubeflow Katib repo! 🎉

Thanks for opening your first PR! We're excited to have you onboard 🚀

Next steps:

Feel free to ask questions in the comments. Thanks again for contributing! 🙏

Signed-off-by: immanuwell <pchpr.00@list.ru>
@immanuwell immanuwell force-pushed the fix/json-metrics-timestamp-parsing branch from bb283d8 to 5b31599 Compare June 13, 2026 06:02
@immanuwell

Copy link
Copy Markdown
Author

@anencore94 @Electronic-Waste @gaocegege please take a look

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant