Skip to content

Feat: tenant per log in Clickhouse adapter#109

Merged
lohanidamodar merged 5 commits intomainfrom
feat-tenant-per-log-ch
Feb 2, 2026
Merged

Feat: tenant per log in Clickhouse adapter#109
lohanidamodar merged 5 commits intomainfrom
feat-tenant-per-log-ch

Conversation

@lohanidamodar
Copy link
Contributor

@lohanidamodar lohanidamodar commented Feb 2, 2026

  • Support tenant per log in clickhouse adapter batch logging
  • Refactor create to utilize createBatch

Summary by CodeRabbit

  • New Features

    • Added batch insertion for audit logs for more efficient multi-log writes.
    • Support for per-log IDs with automatic generation when not provided.
    • Improved tenant handling for multi-tenant setups.
    • Centralized timestamp formatting for consistent log times.
  • Bug Fixes

    • Ensured created logs are consistently retrievable after insertion and validated required attributes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Caution

Review failed

The pull request is closed.

Walkthrough

The ClickHouse adapter (src/Audit/Adapter/ClickHouse.php) was refactored to centralize insertion logic. create() now delegates to a new public createBatch(array $logs): bool by wrapping a single log. createBatch handles per-log id assignment (uses provided id or generates one), time formatting via formatDateTime, tenant resolution from log['$tenant'] or the adapter, schema attribute mapping, and encodes remaining fields into the data column before performing a JSONEachRow batch insert. getById() and find() keep their retrieval behavior with minor docblock edits.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feat: tenant per log in Clickhouse adapter' directly reflects the PR's main objective: supporting tenant-per-log functionality in the ClickHouse adapter, as confirmed by the PR description and commit messages.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-tenant-per-log-ch

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 and usage tips.

$logId = uniqid('', true);
// Generate ID if not provided
$logId = $log['id'] ?? uniqid('', true);
assert(is_string($logId));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's if/throw instead of assert, whether assertions do anything depends on PHP flags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@lohanidamodar lohanidamodar merged commit 1865d05 into main Feb 2, 2026
3 of 4 checks passed
@lohanidamodar lohanidamodar deleted the feat-tenant-per-log-ch branch February 2, 2026 09:49
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.

2 participants