Class QueueItemMetricsEvent

java.lang.Object
jenkins.metrics.api.QueueItemMetricsEvent

public final class QueueItemMetricsEvent extends Object
Holds the metrics about a queue item.
  • Constructor Details

    • 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 Details

    • compareEventSequence

      public static int compareEventSequence(QueueItemMetricsEvent x, QueueItemMetricsEvent y)
      Parameters:
      x - the first QueueItemMetricsEvent to compare
      y - the second QueueItemMetricsEvent to compare
      Returns:
      the value 0 if both events happend at the same time; a value less than 0 if x happened before y; and a value greater than 0 if y happened before x
    • compareQueueSequence

      public static int compareQueueSequence(QueueItemMetricsEvent x, QueueItemMetricsEvent y)
      Parameters:
      x - the first QueueItemMetricsEvent to compare
      y - the second QueueItemMetricsEvent to compare
      Returns:
      the value 0 if both events happend at the same time; a value less than 0 if x was enqueued before y; and a value greater than 0 if y was enqueued before x
    • getEventTick

      public long getEventTick()
      Returns the System.nanoTime() comparable tick when this event occurred.
      Returns:
      the System.nanoTime() comparable tick when this event occurred.
    • getEventMillis

      public long getEventMillis()
      Returns the current System.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 of System.currentTimeMillis() at the time of the event. Compare getEventTick() with System.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 the Queue.Item.getId().
      Returns:
      the Queue.Item.getId().
    • getState

      public QueueItemMetricsEvent.State getState()
      Returns the state of the Queue.Item when the event occurred.
      Returns:
      the state of the Queue.Item when the event occurred.
    • getItem

      @NonNull public Queue.Item getItem()
      Returns the Queue.Item.
      Returns:
      the Queue.Item.
    • getAssignedLabel

      @CheckForNull public Label getAssignedLabel()
      Returns the Queue.Item.getAssignedLabel() at the time of the event or null if the item was not assigned to a label.
      Returns:
      the Queue.Item.getAssignedLabel() at the time of the event or null if the item was not assigned to a label.
    • getRun

      public Optional<Run<?,?>> getRun()
      Returns the Run to which the Queue.Item belongs.
      Returns:
      the Run to which the Queue.Item belongs, if present.
    • getExecutable

      @NonNull public Optional<Queue.Executable> getExecutable()
      Returns the Queue.Executable created from the Queue.Item belongs.
      Returns:
      the Queue.Executable created from the Queue.Item belongs, if present.
    • getConsumedLabelAtoms

      @NonNull public Optional<List<Set<LabelAtom>>> getConsumedLabelAtoms()
      Returns the Node.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, otherwise Optional.empty().
    • getQueuingTotalMillis

      @NonNull public Optional<Long> getQueuingTotalMillis()
      If the Queue.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, otherwise Optional.empty().
    • getQueuingWaitingMillis

      @NonNull public Optional<Long> getQueuingWaitingMillis()
      If the Queue.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, otherwise Optional.empty().
    • getQueuingBlockedMillis

      @NonNull public Optional<Long> getQueuingBlockedMillis()
      If the Queue.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, otherwise Optional.empty().
    • getQueuingBuildableMillis

      @NonNull public Optional<Long> getQueuingBuildableMillis()
      If the Queue.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, otherwise Optional.empty().
    • getExecutingMillis

      @NonNull public Optional<Long> getExecutingMillis()
      If the Queue.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, otherwise Optional.empty().
    • getExecutorCount

      @NonNull public Optional<Integer> getExecutorCount()
      If the Queue.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, otherwise Optional.empty().
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object