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

Return subtask map #1

Merged
merged 2 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<java.level>8</java.level>
<jenkins.version>2.222.1</jenkins.version>
<metrics.version>4.1.6</metrics.version>
<revision>4.0.2.9</revision>
<revision>4.0.2.11</revision>
matchand-nokia marked this conversation as resolved.
Show resolved Hide resolved
<changelist>-SNAPSHOT</changelist>
</properties>

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/jenkins/metrics/impl/TimeInQueueAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import hudson.model.queue.SubTask;
import java.io.Serializable;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import jenkins.model.RunAction2;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
Expand Down Expand Up @@ -158,6 +160,27 @@ public long getQueuingTimeMillis() {
return total;
}

/**
* Returns the total time this {@link Run} spent queuing, including the time spent by subtasks. This is the sum
* of {@link #getQueuingDurationMillis()} plus all the {@link SubTaskTimeInQueueAction#getQueuingDurationMillis()}.
*
* @return the total time this {@link Run} spent queuing
*/
matchand-nokia marked this conversation as resolved.
Show resolved Hide resolved
@Exported(visibility = 2)
public Map<String, Long> getSubTaskMap() {

Map<String, Long> subtasks = new HashMap<String, Long>();
if (run == null) {
return subtasks;
}
int subtask_count = 0;
for (SubTaskTimeInQueueAction t : run.getActions(SubTaskTimeInQueueAction.class)) {
subtasks.put("Subtask_" + subtask_count, t.getQueuingDurationMillis());
subtask_count = subtask_count + 1;
}
return subtasks;
}

/**
* Returns the total time this {@link Run}, and any associated {@link SubTask}s, spent in the queue because they
* were blocked.
Expand Down