Add a gauge to measure build waiting time.#81
Conversation
|
|
||
| tags.add("job:" + builddata.get("job")); | ||
| if ( (builddata.get("node") != null) && DatadogUtilities.getDatadogDescriptor().getTagNode() ) { | ||
| if ( (builddata.get("node") != null) && descriptor.getTagNode() != null && descriptor.getTagNode() ) { |
There was a problem hiding this comment.
This was throwing a NPE upon completion of every build if you were running Jenkins with the Datadog plugin installed but not configured.
The problem was the tagNode variable (in DatadogBuildListener) is null, but the getTagNode method tries to coerce it to a Boolean and fails. Another possible way to fix this could be to make getTagNode detect this case and just return false instead. I'm happy to make this change if you feel that it's better.
There was a problem hiding this comment.
Sure, no problem. It's removed in the most recent update.
sjenriquez
left a comment
There was a problem hiding this comment.
@bbeck Thanks for the PR, this will be a great enhancement! I left a few comments but looks great overall.
|
|
||
| tags.add("job:" + builddata.get("job")); | ||
| if ( (builddata.get("node") != null) && DatadogUtilities.getDatadogDescriptor().getTagNode() ) { | ||
| if ( (builddata.get("node") != null) && descriptor.getTagNode() != null && descriptor.getTagNode() ) { |
| } catch (InterruptedException ex) { | ||
| logger.severe(ex.getMessage()); | ||
| } | ||
|
|
There was a problem hiding this comment.
I think we should abstract this to a new method in DataUtilities.java so we can use it for future metrics as well. I was playing around with this and added this method:
/**
* Builds extraTags if any are configured in the Job
*
* @param run - Current build
* @param listener - Current listener
* @return A {@link HashMap} containing the key,value pairs of tags if any.
*/
public static HashMap<String,String> buildExtraTags(Run run, TaskListener listener) {
HashMap<String,String> extraTags = new HashMap<String, String>();
try {
extraTags = DatadogUtilities.parseTagList(run, listener);
} catch (IOException ex) {
logger.severe(ex.getMessage());
} catch (InterruptedException ex) {
logger.severe(ex.getMessage());
}
return extraTags;
}
Then we can just add these lines here and on line 160 as well:
HashMap<String,String> extraTags = new HashMap<String, String>();
extraTags = DatadogUtilities.buildExtraTags(run, listener);
There was a problem hiding this comment.
Sure. Just pushed an update that introduces this helper like you suggested.
|
Thanks @bbeck, this looks good to go. Can you just rebase on master to resolve the merge conflict? |
|
@sjenriquez Resolved the merge conflict and squashed commits. It does look however like some tests are failing possibly related to this PR -- it seems that |
|
@bbeck Sorry for the troubles here, indeed a PR was merged that broke the tests. This has been resolved and we've set up Travis-CI to avoid these issues in the future. Could you please resolve the conflicts and push one more time. Thanks! |
* datadog/master: push back date fix date add release date update changelog update changelog update changelog
|
@sjenriquez Sorry for the delay. I resolved conflicts, but the tests are still failing for what seems to be the same reason. |
|
Hey @bbeck, looks like we need some additional mocking. More info available here. Check out the diff, tests are ✅ for me with these changes. |
|
Thanks @bbeck ! |
With a dynamically sized pool of agents it's important to know if you're scaling
appropriately and where you need to add more capacity. This PR adds a metric for
each build to let you know how long it had to wait in the queue before executing.