Implement running jobs metric + update metrics code#407
Conversation
a03b079 to
e9bdcc4
Compare
drodriguezhdez
left a comment
There was a problem hiding this comment.
Dropped some comments
| metrics.gauge("jenkins.job.build_duration", buildDuration / 1000, hostname, tags); | ||
| metrics.gauge("jenkins.job.pause_duration", TimeUnit.MILLISECONDS.toSeconds(pauseDurationMillis), hostname, tags); | ||
| logger.fine(String.format("[%s]: Pause Duration: %s", buildData.getJobName(), toTimeString(pauseDurationMillis))); | ||
| long buildDuration = run.getDuration() - pauseDurationMillis; |
There was a problem hiding this comment.
| long buildDuration = run.getDuration() - pauseDurationMillis; | |
| long buildDurationMillis = run.getDuration() - pauseDurationMillis; |
At some point, probably we want to start using java.time.Duration and java.time.Instant to get rid of these xxxMillis suffixes everywhere, now that JDK 1.8 is a requirement for the plugin. (Not blocker for this PR, tho)
There was a problem hiding this comment.
Agree about the java.time usage. Added the suffix for now :)
| return; | ||
| } | ||
| logger.fine("increment counter with dogStatD client"); | ||
| statsd.count(name, value, TagsUtil.convertTagsToArray(tags)); |
There was a problem hiding this comment.
| statsd.count(name, value, TagsUtil.convertTagsToArray(tags)); | |
| String[] tagsArr = (tags != null) ? TagsUtil.convertTagsToArray(tags) : EMPTY_ARRAY; | |
| statsd.count(name, value, TagsUtil.convertTagsToArray(tagsArr)); |
Or even better, modify the TagsUtil.convertTagsToArray method to be resilient for null tags.
In the DatadogApiClient class, we're checking this.
There was a problem hiding this comment.
Added a null-check in TagsUtil.convertTagsToArray
| metrics.gauge("jenkins.node.count", nodeCount, hostname, globalTags); | ||
| metrics.gauge("jenkins.node.offline", nodeOffline, hostname, globalTags); | ||
| metrics.gauge("jenkins.node.online", nodeOnline, hostname, globalTags); | ||
| metrics.gauge("jenkins.job.currently_building", getCurrentRunCount(computers), hostname, globalTags); |
There was a problem hiding this comment.
Is it possible to add a test for this new metric?
There was a problem hiding this comment.
Added an integration test
114903e to
e3c5e9a
Compare
This reverts commit 2074828.
What does this PR do?
Adds new
jenkins.job.currently_buildingmetric which is a gauge of how many jobs are currently executing (the difference compared to existing "busy executors count" is that multiple executors can run parallel task from the same job).Also some of the code that accumulates global counter metrics is refactored.
Description of the Change
Alternate Designs
Possible Drawbacks
Verification Process
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
changelog/label attached. If applicable it should have thebackward-incompatiblelabel attached.do-not-merge/label attached.kind/andseverity/labels attached at least.