Skip to content

Add stage_pause_duration metric#191

Merged
coignetp merged 3 commits into
masterfrom
paul/stage-pause-duration
Mar 24, 2021
Merged

Add stage_pause_duration metric#191
coignetp merged 3 commits into
masterfrom
paul/stage-pause-duration

Conversation

@coignetp

Copy link
Copy Markdown
Contributor

What does this PR do?

Add jenkins.job.stage_pause_duration metric. The value is the pause duration of a stage in milliseconds.
A pause can be a stage waiting for a user input.

Description of the Change

Each time onNewHead is called, it goes over the execution between startNode and endNode, to sum the pause durations of all the subnodes.
It uses the FlowNodeExt wrapper to get the pause duration of a node

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

The loops in getPauseDuration are needed to get the sub-node pause durations, in order to have an accurate jenkins.job.stage_pause_duration metric value for nested stages.

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@coignetp coignetp added the changelog/Added Added features results into a minor version bump label Mar 23, 2021
@coignetp
coignetp marked this pull request as draft March 23, 2021 09:47
@github-actions github-actions Bot added the documentation Documentation related changes label Mar 23, 2021
@coignetp
coignetp marked this pull request as ready for review March 23, 2021 11:03
@hithwen
hithwen requested a review from drodriguezhdez March 23, 2021 16:53
FlorianVeaux
FlorianVeaux previously approved these changes Mar 24, 2021
long pauseDuration = getPauseDuration(startNode);

client.gauge("jenkins.job.stage_duration", getTime(startNode, endNode), hostname, tags);
client.gauge("jenkins.job.stage_pause_duration", pauseDuration, hostname, tags);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure to update the metadata.csv for that metric so that it is displayed as ms


Iterator<FlowNode> it = walker.iterator();

// Iterate on the execution nodes to include pause duration of sub-stages

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a small comment to explain that part.

QQ: The FlowGraphWalker is instantiated while the pipeline is running (because called in onNewHead).
Are we sure this is safe to iterate through all nodes and are we sure we get the correct pause value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: The FlowGraphWalker is instantiated while the pipeline is running (because called in onNewHead).
Are we sure this is safe to iterate through all nodes and are we sure we get the correct pause value?

Even if the pipeline is running, nodes for which startNode is a parent are finished at this point. I added a condition to make sure we consider non-active nodes.

@FlorianVeaux

Copy link
Copy Markdown
Contributor

Great job with this PR 👏

@coignetp
coignetp merged commit 0731ad9 into master Mar 24, 2021
@coignetp
coignetp deleted the paul/stage-pause-duration branch March 24, 2021 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/Added Added features results into a minor version bump documentation Documentation related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants