Skip to content
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

[JENKINS-73788] Reduce metrics bloat relating to provisioning requests #1604

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.csanchez.jenkins.plugins.kubernetes.MetricNames.metricNameForLabel;

import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
Expand Down Expand Up @@ -599,7 +598,6 @@ public Collection<NodeProvisioner.PlannedNode> provision(
@NonNull final Cloud.CloudState state, final int excessWorkload) {
var limitRegistrationResults = new LimitRegistrationResults(this);
try {
Metrics.metricRegistry().meter(metricNameForLabel(state.getLabel())).mark(excessWorkload);
Label label = state.getLabel();
// Planned nodes, will be launched on the next round of NodeProvisioner
int plannedCapacity = state.getAdditionalPlannedCapacity();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.csanchez.jenkins.plugins.kubernetes;

import hudson.model.Label;
import java.util.Locale;

public class MetricNames {
Expand All @@ -21,9 +20,4 @@ public static String metricNameForPodStatus(String status) {
String formattedStatus = status == null ? "null" : status.toLowerCase(Locale.getDefault());
return PREFIX + ".pods.launch.status." + formattedStatus;
}

public static String metricNameForLabel(Label label) {
String labelText = (label == null) ? "nolabel" : label.getDisplayName();
return String.format("%s.%s.provision.request", PREFIX, labelText);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.csanchez.jenkins.plugins.kubernetes;

import hudson.model.labels.LabelAtom;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -29,20 +28,4 @@ public void metricNameForPodStatusChangeStatusToLowercase() {

Assert.assertEquals(expected, actual);
}

@Test
public void metricNameForLabelAddsNoLabelIfLabelIsNull() {
String expected = "kubernetes.cloud.nolabel.provision.request";
String actual = MetricNames.metricNameForLabel(null);

Assert.assertEquals(expected, actual);
}

@Test
public void metricNameForLabelAddsLabelValue() {
String expected = "kubernetes.cloud.java.provision.request";
String actual = MetricNames.metricNameForLabel(new LabelAtom("java"));

Assert.assertEquals(expected, actual);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,6 @@ public void runInPod() throws Exception {
emptyIterable());

assertTrue(Metrics.metricRegistry().counter(MetricNames.PODS_LAUNCHED).getCount() > 0);
assertTrue(Metrics.metricRegistry()
.meter(MetricNames.metricNameForLabel(Label.parseExpression("runInPod")))
.getCount()
> 0);
}

@Test
Expand Down