Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3523 +/- ##
==========================================
- Coverage 95.94% 95.93% -0.01%
==========================================
Files 405 407 +2
Lines 25282 25338 +56
Branches 658 657 -1
==========================================
+ Hits 24257 24309 +52
Misses 489 489
- Partials 536 540 +4
🚀 New features to boost your workflow:
|
576da9d to
5db3365
Compare
65c77be to
e189f67
Compare
|
|
||
| (deftest log-metrics-test | ||
| (testing "logs at info level when below threshold" | ||
| (is (nil? (jml/log-metrics! 100)))) |
There was a problem hiding this comment.
The log-metrics-test only asserts the return value is nil, and the scheduled-*-task-test tests assert (is true) after a sleep. None of these verify that:
- The correct log level (INFO vs WARN) was used
- Logging actually occurred
- The rate-limiting logic throttles info logs to
default-interval
Since this feature is specifically about logging at the right level under the right conditions, capturing log output (e.g., via a Timbre appender or with-redefs) would make these tests much more meaningful.
| (let [heap ^MemoryUsage (.getHeapMemoryUsage (ManagementFactory/getMemoryMXBean)) | ||
| pct (heap-pct heap) | ||
| now (System/nanoTime)] | ||
| (cond |
There was a problem hiding this comment.
Nit: last-info-log is initialized to 0, relying on (- (System/nanoTime) 0) being large enough to trigger the first log. System/nanoTime has no guaranteed epoch — its contract only says differences between two calls are meaningful. Initializing to (- (System/nanoTime) default-nanos) would make the "log immediately on first tick" intent explicit and correct by contract.
There was a problem hiding this comment.
done via a combination of interval and warn-factor
| (let [heap ^MemoryUsage (.getHeapMemoryUsage (ManagementFactory/getMemoryMXBean)) | ||
| non-heap ^MemoryUsage (.getNonHeapMemoryUsage (ManagementFactory/getMemoryMXBean)) | ||
| pct (heap-pct heap) | ||
| gcs (seq (ManagementFactory/getGarbageCollectorMXBeans)) |
There was a problem hiding this comment.
Nit: ManagementFactory/getMemoryMXBean is called twice here (returns the same singleton). Binding it once would be slightly cleaner:
(let [mbean (ManagementFactory/getMemoryMXBean)
heap ^MemoryUsage (.getHeapMemoryUsage mbean)
non-heap ^MemoryUsage (.getNonHeapMemoryUsage mbean)| java-time.api/duration? | ||
| "PT1M"] | ||
| :warn-threshold #blaze/cfg ["JVM_METRICS_LOGGER_WARN_THRESHOLD" pos-int? 80]} | ||
|
|
There was a problem hiding this comment.
Nit: The coercer here is pos-int? which accepts any positive integer, but the spec constrains to 1–99. Setting JVM_METRICS_LOGGER_WARN_THRESHOLD=100 would pass coercion but fail with a spec error at startup. Not blocking (the spec catches it), but the resulting error message won't be as friendly as a dedicated bounds check.
6af1eb5 to
502831c
Compare
502831c to
56db06d
Compare
Closes: #3522