-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add stage breakdown to Jenkins Build/Pipelines traces. #158
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/org/datadog/jenkins/plugins/datadog/model/StageBreakdownAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.datadog.jenkins.plugins.datadog.model; | ||
|
||
import hudson.model.InvisibleAction; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Keeps the Stage breakdown related information. | ||
*/ | ||
public class StageBreakdownAction extends InvisibleAction implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private final Map<String, StageData> stageDataByName; | ||
|
||
public StageBreakdownAction() { | ||
this.stageDataByName = new HashMap<>(); | ||
} | ||
|
||
public Map<String, StageData> getStageDataByName() { | ||
return stageDataByName; | ||
} | ||
|
||
public void put(String name, StageData stageData) { | ||
this.stageDataByName.put(name, stageData); | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
src/main/java/org/datadog/jenkins/plugins/datadog/model/StageData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package org.datadog.jenkins.plugins.datadog.model; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Keeps the information of a Stage to calculate the Stage breakdown. | ||
*/ | ||
public class StageData implements Serializable, Comparable<StageData> { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Expose | ||
private final String name; | ||
@Expose(serialize = false) | ||
private final long startTimeInMicros; | ||
@Expose(serialize = false) | ||
private final long endTimeInMicros; | ||
@Expose | ||
@SerializedName("duration") | ||
private final long durationInNanos; | ||
|
||
private StageData(final Builder builder) { | ||
this.name = builder.name; | ||
this.startTimeInMicros = builder.start; | ||
this.endTimeInMicros = builder.end; | ||
this.durationInNanos = (this.endTimeInMicros - this.startTimeInMicros) * 1000; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public long getStartTimeInMicros() { | ||
return startTimeInMicros; | ||
} | ||
|
||
public long getEndTimeInMicros() { | ||
return endTimeInMicros; | ||
} | ||
|
||
public long getDurationInNanos() { | ||
return durationInNanos; | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
@Override | ||
public int compareTo(StageData other) { | ||
if(this.startTimeInMicros < other.getStartTimeInMicros()) { | ||
return -1; | ||
} else if(this.startTimeInMicros > other.getStartTimeInMicros()) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
StageData stageData = (StageData) o; | ||
return startTimeInMicros == stageData.startTimeInMicros; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(startTimeInMicros); | ||
} | ||
|
||
public static class Builder { | ||
private String name; | ||
private long start; | ||
private long end; | ||
|
||
public Builder withName(final String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public Builder withStartTimeInMicros(final long start){ | ||
this.start = start; | ||
return this; | ||
} | ||
|
||
public Builder withEndTimeInMicros(final long end) { | ||
this.end = end; | ||
return this; | ||
} | ||
|
||
public StageData build() { | ||
return new StageData(this); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("StageData{"); | ||
sb.append("name='").append(name).append('\''); | ||
sb.append(", startTimeInMicros=").append(startTimeInMicros); | ||
sb.append(", endTimeInMicros=").append(endTimeInMicros); | ||
sb.append(", durationInMicros=").append(durationInNanos); | ||
sb.append('}'); | ||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does this package need to be added to
pom.xml
?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.
Not needed because is inherited by the jenkins dependencies