chore(release): Prepare v2.3.0 - #44
Conversation
feat(logging): Add MySQL backend and exclusive Mongo/MySQL selection
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
PR Summary by QodoPrepare v2.3.0: optional Mongo driver + MySQL structured logging backend
AI Description
Diagram
High-Level Assessment
Files changed (42)
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #44 +/- ##
============================================
+ Coverage 98.82% 98.84% +0.01%
- Complexity 949 1023 +74
============================================
Files 70 76 +6
Lines 2219 2430 +211
============================================
+ Hits 2193 2402 +209
- Misses 26 28 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Review by Qodo
1. Hard MongoDB\Collection typehint
|
| use JOOservices\Client\Logging\MongoDbLogger; | ||
| use JOOservices\Client\Logging\MySqlLogConfig; | ||
| use JOOservices\Client\Logging\MySqlLogger; | ||
| use MongoDB\Collection; |
There was a problem hiding this comment.
1. Hard mongodb\collection typehint 📘 Rule violation ☼ Reliability
ClientBuilder always loads LoggingBuilderMethods, which imports and typehints MongoDB\Collection; this makes mongodb/mongodb effectively required at runtime even though it was moved to composer.json:suggest. Consumers without the Mongo driver can hit a fatal class-resolution error just by loading the builder, breaking the “optional backend” requirement.
Agent Prompt
## Issue description
`mongodb/mongodb` was moved to `composer.json:suggest`, but `src/Client/LoggingBuilderMethods.php` imports and typehints `MongoDB\Collection`. Because `ClientBuilder` unconditionally uses this trait, the package can require the MongoDB classes to exist at load time, defeating the goal of keeping Mongo logging optional.
## Issue Context
Compliance requires MongoDB/MySQL structured logging backends remain optional and not introduce hard dependency requirements for consumers who do not use them.
## Fix Focus Areas
- src/Client/LoggingBuilderMethods.php[7-33]
- src/Client/ClientBuilder.php[85-90]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| return $this->cache->set($cacheKey, $current + 1); | ||
| } |
There was a problem hiding this comment.
2. Bulkhead counter never expires 🐞 Bug ☼ Reliability
Psr16BulkheadStore::tryAcquire() increments the active counter via PSR-16 set() without any TTL, so a process crash/kill between acquire and the finally-based release can leave a stale count that blocks future requests for that partition. This is specific to the new PSR-16 bulkhead store because the value represents in-flight work but is persisted indefinitely.
Agent Prompt
### Issue description
`Psr16BulkheadStore` stores an “active in-flight requests” counter in PSR-16 without expiry. If the PHP worker terminates before `BulkheadMiddleware` reaches its `finally` block, the counter can remain non-zero indefinitely and the partition will be rejected until manual cache cleanup.
### Issue Context
This store is meant to represent *in-flight* concurrency, unlike circuit/rate-limit state which can safely persist. A TTL/lease mechanism is needed to self-heal from unclean shutdowns.
### Fix Focus Areas
- src/Resilience/Storage/Psr16BulkheadStore.php[19-61]
- src/Middleware/BulkheadMiddleware.php[24-37]
### Implementation notes
- Add a configurable TTL/lease duration (e.g., constructor parameter like `$leaseSeconds`, default conservative value).
- Pass that TTL to `CacheInterface::set()` in `tryAcquire()` and also when decrementing in `release()` (refresh/extend as needed).
- Document the tradeoff: TTL must exceed maximum expected request duration; otherwise long requests could expire and undercount.
- Add/adjust unit tests to cover TTL usage (at least asserting `set()` is called with TTL via a spy cache).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| return static function (array $document) use ($pdo, $sql): void { | ||
| $statement = $pdo->prepare($sql); | ||
| $statement->execute(MySqlLogRowMapper::toRow($document)); | ||
| }; |
There was a problem hiding this comment.
3. Prepare per log entry 🐞 Bug ➹ Performance
MySqlLogger::createPdoWriter() prepares the same INSERT statement on every log write, and LoggingMiddleware emits multiple log entries per request, causing repeated prepare() overhead on hot paths. This can significantly increase latency and DB load under high request volume.
Agent Prompt
### Issue description
The default PDO writer created by `MySqlLogger::createPdoWriter()` calls `$pdo->prepare($sql)` for every log document. Since the middleware logs at least “Sending request” and “Received response” per HTTP call, this results in multiple prepares per request.
### Issue Context
The writer closure is created once per logger instance and captures the PDO connection and SQL string, so it can also capture a prepared `PDOStatement` and reuse it.
### Fix Focus Areas
- src/Logging/MySqlLogger.php[204-215]
- src/Middleware/LoggingMiddleware.php[51-75]
### Implementation notes
- Prepare once when building the writer:
- `$statement = $pdo->prepare($sql);` outside the returned closure.
- If `$statement === false`, throw `InvalidConfigurationException` (fail fast on misconfigured schema/SQL).
- In the closure, only call `$statement->execute(MySqlLogRowMapper::toRow($document));`.
- Consider whether you need to re-prepare on failure (optional), but the minimum improvement is statement reuse.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
developafter merging feat(logging): Add MySQL backend and exclusive Mongo/MySQL selection #43 (MySQL structured logging, exclusive Mongo/MySQL backend selection, soft Mongo dependency, bulkhead/store and audit remediations).develop(CHANGELOG.md[2.3.0], release target 2.3.0).Test plan
composer cipath via workflows)master: tagv2.3.0, verify GitHub Release + Packagist updatemasterback intodevelop