Class NullObservation

java.lang.Object
io.micrometer.observation.NullObservation
All Implemented Interfaces:
Observation, ObservationView

public class NullObservation extends Object
A special Observation that should be used only in special cases where clearing of scopes is important. It will not call any handler methods except for scope related ones.
Since:
1.10.8
See Also:
  • Constructor Details

  • Method Details

    • start

      public Observation start()
      Description copied from interface: Observation
      Starts the observation. Remember to call this method, otherwise timing calculations will not take place.
      Specified by:
      start in interface Observation
      Returns:
      this
    • contextualName

      public Observation contextualName(@Nullable String contextualName)
      Description copied from interface: Observation
      Sets the name that can be defined from the contents of the context. E.g. a span name should not be the default observation name but one coming from an HTTP request.
      Specified by:
      contextualName in interface Observation
      Parameters:
      contextualName - contextual name
      Returns:
      this
    • parentObservation

      public Observation parentObservation(@Nullable Observation parentObservation)
      Description copied from interface: Observation
      If you have access to a previously created Observation you can manually set the parent Observation using this method - that way you won't need to open scopes just to create a child observation. If you're using the Observation.openScope() method then the parent observation will be automatically set, and you don't have to call this method.
      Specified by:
      parentObservation in interface Observation
      Parameters:
      parentObservation - parent observation to set
      Returns:
      this
    • lowCardinalityKeyValue

      public Observation lowCardinalityKeyValue(io.micrometer.common.KeyValue keyValue)
      Description copied from interface: Observation
      Adds a low cardinality key value. Low cardinality means that this key value will have a bounded number of possible values. A templated HTTP URL is a good example of such a key value (e.g. /foo/{userId}).
      Specified by:
      lowCardinalityKeyValue in interface Observation
      Parameters:
      keyValue - key value
      Returns:
      this
    • highCardinalityKeyValue

      public Observation highCardinalityKeyValue(io.micrometer.common.KeyValue keyValue)
      Description copied from interface: Observation
      Adds a high cardinality key value. High cardinality means that this key value will have an unbounded number of possible values. An HTTP URL is a good example of such a key value (e.g. /foo/bar, /foo/baz etc.).
      Specified by:
      highCardinalityKeyValue in interface Observation
      Parameters:
      keyValue - key value
      Returns:
      this
    • observationConvention

      public Observation observationConvention(ObservationConvention<?> convention)
      Description copied from interface: Observation
      Sets an observation convention that can be used to attach key values to the observation. Implementations should only set the convention when it supports (see: ObservationConvention.supportsContext(Context)) the current Observation.Context. WARNING: You must set the ObservationConvention to the Observation before it is started.
      Specified by:
      observationConvention in interface Observation
      Parameters:
      convention - observation convention
      Returns:
      this
    • error

      public Observation error(Throwable error)
      Description copied from interface: Observation
      Signals an error.
      Specified by:
      error in interface Observation
      Parameters:
      error - error
      Returns:
      this
    • event

      public Observation event(Observation.Event event)
      Description copied from interface: Observation
      Signals an arbitrary Observation.Event.
      Specified by:
      event in interface Observation
      Parameters:
      event - event
      Returns:
      this
    • getContext

      public Observation.Context getContext()
      Description copied from interface: Observation
      Returns the context attached to this observation.
      Specified by:
      getContext in interface Observation
      Returns:
      corresponding context
    • stop

      public void stop()
      Description copied from interface: Observation
      Stop the observation. Remember to call this method, otherwise timing calculations won't be finished.
      Specified by:
      stop in interface Observation
    • openScope

      public Observation.Scope openScope()
      Description copied from interface: Observation
      When put in scope, additional operations can take place by the ObservationHandlers such as putting entries in thread local.
      Specified by:
      openScope in interface Observation
      Returns:
      new scope
    • getEnclosingScope

      @Nullable public Observation.Scope getEnclosingScope()
      Description copied from interface: ObservationView
      Pops the last scope attached to this ObservationView in this thread.
      Specified by:
      getEnclosingScope in interface ObservationView
      Returns:
      scope for this ObservationView, null if there was no scope
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getObservationRegistry

      public ObservationRegistry getObservationRegistry()
      Description copied from interface: ObservationView
      Returns the ObservationRegistry attached to this observation.
      Specified by:
      getObservationRegistry in interface ObservationView
      Returns:
      corresponding observation registry