Interface Observation.Scope

All Superinterfaces:
AutoCloseable
Enclosing interface:
Observation

public static interface Observation.Scope extends AutoCloseable
Scope represent an action within which certain resources (e.g. tracing context) are put in scope (e.g. in a ThreadLocal). When the scope is closed the resources will be removed from the scope.
Since:
1.10.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Observation.Scope
    No-op scope.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the current scope and notifies the handlers that the scope was closed.
    Current observation available within this scope.
    default @Nullable Observation.Scope
    Parent scope.
    default boolean
    Checks whether this Observation.Scope is no-op.
    void
    Deprecated.
    This method will be removed in a future release.
    void
    Deprecated.
    No longer used by Micrometer code.
  • Field Details

  • Method Details

    • getCurrentObservation

      Observation getCurrentObservation()
      Current observation available within this scope.
      Returns:
      current observation that this scope was created by
    • getPreviousObservationScope

      default @Nullable Observation.Scope getPreviousObservationScope()
      Parent scope.
      Returns:
      previously opened scope when this one was created
      Since:
      1.10.8
    • close

      void close()
      Clears the current scope and notifies the handlers that the scope was closed. You don't need to call this method manually. If you use try-with-resource, it will call this for you. Please only call this method if you know what you are doing and your use-case demands the usage of it.
      Specified by:
      close in interface AutoCloseable
    • reset

      @Deprecated void reset()
      Deprecated.
      No longer used by Micrometer code. Use close() instead. This method will be removed in a future release.
      Resets the current scope. The effect of calling this method should be clearing all related thread local entries. You don't need to call this method in most of the cases. Please only call this method if you know what you are doing and your use-case demands the usage of it.
      Since:
      1.10.4
    • makeCurrent

      @Deprecated void makeCurrent()
      Deprecated.
      This method will be removed in a future release. It is no longer called by Micrometer code.
      This method assumes that all previous scopes got reset(). That means that in thread locals there are no more entries, and now we can make this scope current. Making this scope current can lead to additional work such as injecting variables to MDC. You don't need to call this method in most of the cases. Please only call this method if you know what you are doing and your use-case demands the usage of it.
      Since:
      1.10.6
    • isNoop

      default boolean isNoop()
      Checks whether this Observation.Scope is no-op.
      Returns:
      true when this is a no-op scope