Skip to content

fix: keep sub-second precision in audit log query window - #615

Open
mevan-karu wants to merge 1 commit into
openchoreo:mainfrom
mevan-karu:fix/audit-logs-subsecond-window
Open

mevan-karu wants to merge 1 commit into
openchoreo:mainfrom
mevan-karu:fix/audit-logs-subsecond-window

Conversation

@mevan-karu

@mevan-karu mevan-karu commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Purpose

The audit log query window was cut to whole seconds before it reached OpenSearch. Paging by the last record's time then skipped records (descending) or returned the same page again (ascending).

Approach

Format startTime and endTime with RFC3339Nano so the range query keeps fractions of a second.

Related Issues

Part of openchoreo/openchoreo#4731

Checklist

  • Tests added or updated (unit, integration, etc.)
  • Samples updated (if applicable)

Remarks

Needed for next-page paging in occ auditlogs.

Summary by CodeRabbit

  • Bug Fixes

    • Audit log time-range queries now preserve sub-second precision, improving the accuracy of event-time filtering.
  • Tests

    • Added coverage to verify that millisecond and microsecond time bounds are retained in audit log searches.

The window was cut to whole seconds, so paging by the last record's time skipped or repeated records.

Signed-off-by: Mevan <mevan.karu@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 88704c33-8635-4939-a7f6-e5abecc3315f

📥 Commits

Reviewing files that changed from the base of the PR and between ccb2c8a and 315d0bd.

📒 Files selected for processing (2)
  • observability-logs-opensearch/internal/audit_handlers.go
  • observability-logs-opensearch/internal/audit_handlers_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Audit log query time bounds now preserve sub-second precision. Tests verify exact microsecond and millisecond values in the generated OpenSearch range filter.

Changes

Audit time precision

Layer / File(s) Summary
Format and validate sub-second bounds
observability-logs-opensearch/internal/audit_handlers.go, observability-logs-opensearch/internal/audit_handlers_test.go
toAuditLogsQueryParams formats start and end times with time.RFC3339Nano. Tests verify exact gte and lt event-time bounds and locate the generated range filter.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 315d0

The audit query retains sub-second time precision with no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required Conventional Commits format and clearly identifies the main change: preserving sub-second precision in audit log query windows.
Description check ✅ Passed The description includes Purpose, Approach, Related Issues, Checklist, and Remarks. It explains the paging problem, the RFC3339Nano solution, and the test updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

3 participants