Record Class TimeRange

java.lang.Object
java.lang.Record
codes.grow.packages.skywalking.TimeRange
Record Components:
start - window start, or empty for end − 1 h
end - window end, or empty for now
step - bucket granularity, or empty for Step.MINUTE

public record TimeRange(Optional<Instant> start, Optional<Instant> end, Optional<Step> step) extends Record
Time window of a metadata, topology, trace or log query. Defaults: end = now, start = end − 1 h (DEFAULT_WINDOW), step = Step.MINUTE. OAP expects the bounds in its own time zone; the client converts them.
  • Field Details

    • DEFAULT_WINDOW

      public static final Duration DEFAULT_WINDOW
      Default query window: one hour.
    • DEFAULT

      public static final TimeRange DEFAULT
      Everything defaulted: the last hour, step MINUTE.
  • Constructor Details

  • Method Details

    • of

      public static TimeRange of(Instant start, Instant end)
      A window between two instants (either may be null).
      Parameters:
      start - start or null
      end - end or null
      Returns:
      the range
    • since

      public static TimeRange since(Instant start)
      A window from start to now.
      Parameters:
      start - start
      Returns:
      the range
    • last

      public static TimeRange last(Duration window)
      The last window until now (resolved when the query runs).
      Parameters:
      window - positive duration
      Returns:
      the range
    • withStep

      public TimeRange withStep(Step step)
      Returns a copy with another step.
      Parameters:
      step - step
      Returns:
      the range
    • isDefault

      public boolean isDefault()
      Whether no bound and no step is set.
      Returns:
      true when everything is defaulted
    • resolve

      public GraphQLDuration.Resolved resolve(Instant now, String operation)
      Applies the defaults and validates.
      Parameters:
      now - current time
      operation - operation name for the error
      Returns:
      the resolved window
      Throws:
      ValidationException - when start is after end
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • start

      public Optional<Instant> start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • end

      public Optional<Instant> end()
      Returns the value of the end record component.
      Returns:
      the value of the end record component
    • step

      public Optional<Step> step()
      Returns the value of the step record component.
      Returns:
      the value of the step record component