Skip to content

Commit

Permalink
Do not collect disabled jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Waschndolos committed Jan 25, 2025
1 parent 02f7f43 commit 27e2c88
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/main/java/org/jenkinsci/plugins/prometheus/JobCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,20 @@ public List<MetricFamilySamples> collect() {

Jobs.forEachJob(job -> {
try {
if (!job.isBuildable() && processDisabledJobs) {
LOGGER.debug("job [{}] is disabled", job.getFullName());
return;
if (job.isBuildable()) {
if (!MetricStatusChecker.isJobEnabled(job.getFullName())) {
LOGGER.debug("Job [{}] is excluded by configuration", job.getFullName());
return;
}
LOGGER.debug("Collecting metrics for job [{}]", job.getFullName());
appendJobMetrics(job);
} else {
if (processDisabledJobs) {
appendJobMetrics(job);
} else {
LOGGER.debug("job [{}] is disabled", job.getFullName());

Check warning on line 171 in src/main/java/org/jenkinsci/plugins/prometheus/JobCollector.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 160-171 are not covered by tests
}
}
if (!MetricStatusChecker.isJobEnabled(job.getFullName())) {
LOGGER.debug("Job [{}] is excluded by configuration", job.getFullName());
return;
}
LOGGER.debug("Collecting metrics for job [{}]", job.getFullName());
appendJobMetrics(job);
} catch (IllegalArgumentException e) {
if (!e.getMessage().contains("Incorrect number of labels")) {
LOGGER.warn("Caught error when processing job [{}] error: ", job.getFullName(), e);
Expand Down

0 comments on commit 27e2c88

Please sign in to comment.