-
Notifications
You must be signed in to change notification settings - Fork 75
Collect information about instance startup and shutdown #646
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
Conversation
Collect timings for each init milestone If the startup takes more than a defined initial delay, start collecting thread dumps at regular intervals.
} | ||
var format = new SimpleDateFormat(DATE_FORMAT); | ||
for (int i = 0; i < iterations; i++) { | ||
File threadDumpFile = fileList.file(format.format(new Date(timestamp)) + ".txt"); |
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.
Suppressed the prefix -i
as the timestamp is always different anyway
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.
(referring to code moved from SlowRequestThreadDumpsGenerator
)
@@ -45,11 +48,41 @@ | |||
@Extension(ordinal = -100.0) // run this last as it blocks the channel | |||
public class ThreadDumps extends ObjectComponent<Computer> { | |||
|
|||
private final Logger logger = Logger.getLogger(ThreadDumps.class.getName()); |
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 due
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.
Looks good so far.
} | ||
var format = new SimpleDateFormat(DATE_FORMAT); | ||
for (int i = 0; i < iterations; i++) { | ||
File threadDumpFile = fileList.file(format.format(new Date(timestamp)) + ".txt"); |
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.
(referring to code moved from SlowRequestThreadDumpsGenerator
)
src/main/java/com/cloudbees/jenkins/support/impl/ThreadDumps.java
Outdated
Show resolved
Hide resolved
src/main/java/com/cloudbees/jenkins/support/impl/ThreadDumps.java
Outdated
Show resolved
Hide resolved
src/main/java/com/cloudbees/jenkins/support/startup/ShutdownComponent.java
Show resolved
Hide resolved
src/main/java/com/cloudbees/jenkins/support/startup/ShutdownComponent.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
protected void printTo(PrintWriter out, @NonNull ContentFilter filter) { | ||
var startTime = ManagementFactory.getRuntimeMXBean().getStartTime(); |
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.
Beware that this is JVM startup time, so if any servlet listener runs before Jenkins starts (two such examples come to mind in CloudBees CI), you will get a very skewed measurement.
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.
I think we don't have any better from core for now...
Collect timings for each init milestone
If the startup takes more than a defined initial delay, start collecting thread dumps at regular intervals, until the startup completes.
We consider that an instance taking more than 5 minutes is slow to start and is worth collecting thread dumps for (
com.cloudbees.jenkins.support.startup.StartupReport.INITIAL_DELAY_SECONDS
).Then we take one thread dump every 30 seconds (
com.cloudbees.jenkins.support.startup.StartupReport.RECURRENCE_PERIOD_SECONDS
)The timings are collected in
startup-timings.md
with the following format (values for a development instance)Total startup time : 30 sec
I will also add a similar logic to collect information when the instance terminates and takes more than the expected time.
CloudBees Internal issue
Testing done
Submitter checklist