Skip to content

Fix NPE when using CGroup metrics with no cpu limit #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

rbygrave
Copy link
Contributor

@rbygrave rbygrave commented Apr 15, 2025

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "io.avaje.metrics.Metric.name()" because "metric" is null
	at io.avaje.metrics.core.DefaultMetricProvider.register(DefaultMetricProvider.java:235)
	at io.avaje.metrics.core.JvmCGroupCpu.create(JvmCGroupCpu.java:33)
	at io.avaje.metrics.core.JvmCGroupCpu.createGauges(JvmCGroupCpu.java:14)
	at io.avaje.metrics.core.DefaultMetricProvider.registerCGroupMetrics(DefaultMetricProvider.java:134)

@rbygrave rbygrave self-assigned this Apr 15, 2025
@@ -30,18 +31,18 @@ void create(MetricRegistry registry, boolean reportChangesOnly) {
FileLines cpuQuota = new FileLines("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us");
FileLines period = new FileLines("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us");
if (cpuQuota.exists() && period.exists()) {
registry.register(createCGroupCpuLimit(cpuQuota, period));
createCGroupCpuLimit(cpuQuota, period).ifPresent(registry::register);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the bug fix here

@rbygrave rbygrave merged commit 55901e6 into master Apr 15, 2025
2 checks passed
@rbygrave rbygrave deleted the feature/fix-npe-cgroup-cpu-limit branch April 15, 2025 00:48
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