-
Notifications
You must be signed in to change notification settings - Fork 52
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
Implement running jobs metric + update metrics code #407
Implement running jobs metric + update metrics code #407
Conversation
a03b079
to
e9bdcc4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a test for this new metric?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an integration test
114903e
to
e3c5e9a
Compare
This reverts commit 2074828.
What does this PR do?
Adds new
jenkins.job.currently_building
metric 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-incompatible
label attached.do-not-merge/
label attached.kind/
andseverity/
labels attached at least.