Skip to content

Conversation

@itssimon
Copy link
Member

@itssimon itssimon commented Jan 23, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • System now monitors and reports CPU and memory usage metrics to provide visibility into resource consumption.

✏️ Tip: You can customize this high-level summary in your review settings.

@itssimon itssimon self-assigned this Jan 23, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Walkthrough

This change introduces resource monitoring capabilities to the Apitally client library. A new ResourceMonitor class, powered by the OSHI library, captures CPU and memory usage metrics. These metrics are packaged into a new ResourceUsage DTO and integrated into the sync data payload sent by ApitallyClient. The Maven dependency is updated to include OSHI, and tests validate the monitoring behavior.

Changes

Cohort / File(s) Summary
Dependency Management
pom.xml
Added OSHI library dependency (v6.9.2) for OS-level system metrics.
Resource Monitoring Framework
src/main/java/io/apitally/common/ResourceMonitor.java, src/main/java/io/apitally/common/dto/ResourceUsage.java
Introduced ResourceMonitor class to track CPU and memory usage with delta calculation. Created immutable ResourceUsage DTO with JSON serialization for cpu_percent and memory_rss fields.
Client Integration
src/main/java/io/apitally/common/ApitallyClient.java, src/main/java/io/apitally/common/dto/SyncData.java
Added resourceMonitor field to ApitallyClient and initialized it in the constructor. Extended SyncData to accept and serialize ResourceUsage metrics in sync payloads.
Test Suite
src/test/java/io/apitally/common/ResourceMonitorTest.java
Added unit test validating that ResourceMonitor.getCpuMemoryUsage() returns null on first call, then valid resource metrics on subsequent calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Capture CPU and memory metrics' directly and accurately summarizes the main change: adding CPU and memory monitoring capability via ResourceMonitor class and ResourceUsage DTO.

✏️ 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 simon/dev-34-capture-cpu-and-memory-metrics-in-java-sdk

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

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.87%. Comparing base (28f8a88) to head (dc0c905).

Files with missing lines Patch % Lines
.../main/java/io/apitally/common/ResourceMonitor.java 75.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #54      +/-   ##
============================================
+ Coverage     78.76%   78.87%   +0.11%     
- Complexity      355      362       +7     
============================================
  Files            34       36       +2     
  Lines          1276     1302      +26     
  Branches        162      164       +2     
============================================
+ Hits           1005     1027      +22     
- Misses          187      190       +3     
- Partials         84       85       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@itssimon itssimon merged commit e5e161c into main Jan 23, 2026
18 checks passed
@itssimon itssimon deleted the simon/dev-34-capture-cpu-and-memory-metrics-in-java-sdk branch January 23, 2026 07:25
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