Package jenkins.metrics.api
Class QueueItemMetricsEvent
- java.lang.Object
-
- jenkins.metrics.api.QueueItemMetricsEvent
-
public final class QueueItemMetricsEvent extends Object
Holds the metrics about a queue item.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QueueItemMetricsEvent.State
The state of the item when this metrics event was created.
-
Constructor Summary
Constructors Constructor Description QueueItemMetricsEvent(Queue.Item item, Label assignedLabel, QueueItemMetricsEvent.State state, Run<?,?> run, Queue.Executable executable, List<Set<LabelAtom>> consumedLabelAtoms, Long queuingTotalMillis, Long queuingWaitingMillis, Long queuingBlockedMillis, Long queuingBuildableMillis, Long executingMillis, Integer executorCount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
compareEventSequence(QueueItemMetricsEvent x, QueueItemMetricsEvent y)
SortsQueueItemMetricsEvent
s bygetEventTick()
.static int
compareQueueSequence(QueueItemMetricsEvent x, QueueItemMetricsEvent y)
SortsQueueItemMetricsEvent
s by the orderQueue.Item.getId()
.boolean
equals(Object o)
Label
getAssignedLabel()
Returns theQueue.Item.getAssignedLabel()
at the time of the event ornull
if the item was not assigned to a label.Optional<List<Set<LabelAtom>>>
getConsumedLabelAtoms()
Returns theNode.getAssignedLabels()
of all the executor slots occupied by this task, if the task has been started.long
getEventMillis()
Returns the currentSystem.currentTimeMillis()
comparable time when this event occurred.long
getEventTick()
Returns theSystem.nanoTime()
comparable tick when this event occurred.Optional<Queue.Executable>
getExecutable()
Returns theQueue.Executable
created from theQueue.Item
belongs.Optional<Long>
getExecutingMillis()
If theQueue.Executable
has finished executing, returns the number of milliseconds the item spent executing.Optional<Integer>
getExecutorCount()
If theQueue.Executable
has started executing, returns the number of executors being used.long
getId()
Returns theQueue.Item.getId()
.Queue.Item
getItem()
Returns theQueue.Item
.Optional<Long>
getQueuingBlockedMillis()
If theQueue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the blocked state.Optional<Long>
getQueuingBuildableMillis()
If theQueue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the buildable state.Optional<Long>
getQueuingTotalMillis()
If theQueue.Item
has left the queue, returns the number of milliseconds the item was on the queue.Optional<Long>
getQueuingWaitingMillis()
If theQueue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the waiting state.Optional<Run<?,?>>
getRun()
Returns theRun
to which theQueue.Item
belongs.QueueItemMetricsEvent.State
getState()
Returns the state of theQueue.Item
when the event occurred.int
hashCode()
String
toString()
-
-
-
Constructor Detail
-
QueueItemMetricsEvent
public QueueItemMetricsEvent(@NonNull Queue.Item item, @CheckForNull Label assignedLabel, @NonNull QueueItemMetricsEvent.State state, @CheckForNull Run<?,?> run, @CheckForNull Queue.Executable executable, @CheckForNull List<Set<LabelAtom>> consumedLabelAtoms, @CheckForNull Long queuingTotalMillis, @CheckForNull Long queuingWaitingMillis, @CheckForNull Long queuingBlockedMillis, @CheckForNull Long queuingBuildableMillis, @CheckForNull Long executingMillis, @CheckForNull Integer executorCount)
-
-
Method Detail
-
compareEventSequence
public static int compareEventSequence(QueueItemMetricsEvent x, QueueItemMetricsEvent y)
SortsQueueItemMetricsEvent
s bygetEventTick()
.- Parameters:
x
- the firstQueueItemMetricsEvent
to comparey
- the secondQueueItemMetricsEvent
to compare- Returns:
- the value
0
if both events happend at the same time; a value less than0
ifx
happened beforey
; and a value greater than0
ify
happened beforex
-
compareQueueSequence
public static int compareQueueSequence(QueueItemMetricsEvent x, QueueItemMetricsEvent y)
SortsQueueItemMetricsEvent
s by the orderQueue.Item.getId()
.- Parameters:
x
- the firstQueueItemMetricsEvent
to comparey
- the secondQueueItemMetricsEvent
to compare- Returns:
- the value
0
if both events happend at the same time; a value less than0
ifx
was enqueued beforey
; and a value greater than0
ify
was enqueued beforex
-
getEventTick
public long getEventTick()
Returns theSystem.nanoTime()
comparable tick when this event occurred.- Returns:
- the
System.nanoTime()
comparable tick when this event occurred.
-
getEventMillis
public long getEventMillis()
Returns the currentSystem.currentTimeMillis()
comparable time when this event occurred. IMPORTANT if the system clock has changed between when the event occurred and now, this function will return the time comparable to now, not the time comparable to the value ofSystem.currentTimeMillis()
at the time of the event. ComparegetEventTick()
withSystem.nanoTime()
if you need to measure the time since the event.- Returns:
- the current
System.currentTimeMillis()
comparable time when this event occurred.
-
getId
public long getId()
Returns theQueue.Item.getId()
.- Returns:
- the
Queue.Item.getId()
.
-
getState
public QueueItemMetricsEvent.State getState()
Returns the state of theQueue.Item
when the event occurred.- Returns:
- the state of the
Queue.Item
when the event occurred.
-
getItem
@NonNull public Queue.Item getItem()
Returns theQueue.Item
.- Returns:
- the
Queue.Item
.
-
getAssignedLabel
@CheckForNull public Label getAssignedLabel()
Returns theQueue.Item.getAssignedLabel()
at the time of the event ornull
if the item was not assigned to a label.- Returns:
- the
Queue.Item.getAssignedLabel()
at the time of the event ornull
if the item was not assigned to a label.
-
getRun
public Optional<Run<?,?>> getRun()
Returns theRun
to which theQueue.Item
belongs.- Returns:
- the
Run
to which theQueue.Item
belongs, if present.
-
getExecutable
@NonNull public Optional<Queue.Executable> getExecutable()
Returns theQueue.Executable
created from theQueue.Item
belongs.- Returns:
- the
Queue.Executable
created from theQueue.Item
belongs, if present.
-
getConsumedLabelAtoms
@NonNull public Optional<List<Set<LabelAtom>>> getConsumedLabelAtoms()
Returns theNode.getAssignedLabels()
of all the executor slots occupied by this task, if the task has been started.- Returns:
- the
Node.getAssignedLabels()
of all the executor slots occupied by this task, if the task has been started, otherwiseOptional.empty()
.
-
getQueuingTotalMillis
@NonNull public Optional<Long> getQueuingTotalMillis()
If theQueue.Item
has left the queue, returns the number of milliseconds the item was on the queue.- Returns:
- if the
Queue.Item
has left the queue, returns the number of milliseconds the item was on the queue, otherwiseOptional.empty()
.
-
getQueuingWaitingMillis
@NonNull public Optional<Long> getQueuingWaitingMillis()
If theQueue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the waiting state.- Returns:
- if the
Queue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the waiting state, otherwiseOptional.empty()
.
-
getQueuingBlockedMillis
@NonNull public Optional<Long> getQueuingBlockedMillis()
If theQueue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the blocked state.- Returns:
- if the
Queue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the blocked state, otherwiseOptional.empty()
.
-
getQueuingBuildableMillis
@NonNull public Optional<Long> getQueuingBuildableMillis()
If theQueue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the buildable state.- Returns:
- if the
Queue.Item
has left the queue, returns the number of milliseconds the item was on the queue in the buildable state, otherwiseOptional.empty()
.
-
getExecutingMillis
@NonNull public Optional<Long> getExecutingMillis()
If theQueue.Executable
has finished executing, returns the number of milliseconds the item spent executing.- Returns:
- if the
Queue.Executable
has finished executing, returns the number of milliseconds the item spent executing, otherwiseOptional.empty()
.
-
getExecutorCount
@NonNull public Optional<Integer> getExecutorCount()
If theQueue.Executable
has started executing, returns the number of executors being used.- Returns:
- if the
Queue.Executable
has started executing, returns the number of executors being used, otherwiseOptional.empty()
.
-
-