Interface Observation.Event

Enclosing interface:
Observation

public static interface Observation.Event
An arbitrary event that you can extend and signal during an Observation. This helps you to tell to the ObservationHandler that something happened. If you want to signal an exception/error, please use Observation.error(Throwable) instead.
  • Method Details

    • of

      static Observation.Event of(String name, String contextualName)
      Creates an Observation.Event for the given names.
      Parameters:
      name - The name of the event (should have low cardinality).
      contextualName - The contextual name of the event (can have high cardinality).
      Returns:
      event
    • of

      static Observation.Event of(String name, String contextualName, long wallTime)
      Creates an Observation.Event for the given names and timestamp (wall time).
      Parameters:
      name - The name of the event (should have low cardinality).
      contextualName - The contextual name of the event (can have high cardinality).
      wallTime - Wall time in milliseconds since the epoch
      Returns:
      event
      Since:
      1.12.0
    • of

      static Observation.Event of(String name)
      Creates an Observation.Event for the given name.
      Parameters:
      name - The name of the event (should have low cardinality).
      Returns:
      event
    • getName

      String getName()
      Returns the name of the event.
      Returns:
      the name of the event.
    • getWallTime

      default long getWallTime()
      Wall time in milliseconds since the epoch. Typically equivalent to System.currentTimeMillis(). Should not be used to determine durations. Used for timestamping events that happened during Observations.
      Returns:
      Wall time in milliseconds since the epoch
      Since:
      1.12.0
    • getContextualName

      default String getContextualName()
      Returns the contextual name of the event. You can use %s to represent dynamic entries that should be resolved at runtime via String.format(String, Object...).
      Returns:
      the contextual name of the event.
    • format

      default Observation.Event format(Object... dynamicEntriesForContextualName)
      Creates a new event with the given dynamic entries for the contextual name.
      Parameters:
      dynamicEntriesForContextualName - variables to be resolved in getContextualName() via String.format(String, Object...).
      Returns:
      event