Top Description Inners Fields Constructors Methods
io.micrometer.observation

pack-priv final Class NoopObservation

extends Object
implements Observation
Class Inheritance
All Implemented Interfaces
io.micrometer.observation.Observation, io.micrometer.observation.ObservationView
Imports
io.micrometer.common.KeyValue, io.micrometer.common.lang.Nullable

No-op implementation of Observation so that we can disable the instrumentation logic.
Authors
Jonatan Ivanov, Tommy Ludwig, Marcin Grzejszczak
Since
1.10.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
NoopObservation.NoopScope

Scope that does nothing.

Field Summary

Modifier and TypeField and Description
private static final Observation.Context

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Observation
contextualName(String
contextual name
contextualName
)

Implements io.micrometer.observation.Observation.contextualName.

Sets the name that can be defined from the contents of the context.
public Observation
error(Throwable
error
error
)

Implements io.micrometer.observation.Observation.error.

Signals an error.
public Observation
event(Observation.Event
event
event
)

Implements io.micrometer.observation.Observation.event.

Signals an arbitrary Event.
public Observation.Context
getContext()

Implements io.micrometer.observation.Observation.getContext.

Returns the context attached to this observation.
public Observation
highCardinalityKeyValue(KeyValue
key value
keyValue
)

Implements io.micrometer.observation.Observation.highCardinalityKeyValue.

Adds a high cardinality key value.
public Observation
highCardinalityKeyValue(String
key
key
,
String
value
value
)

Overrides default io.micrometer.observation.Observation.highCardinalityKeyValue.

Adds a high cardinality key value.
public Observation
lowCardinalityKeyValue(KeyValue
key value
keyValue
)

Implements io.micrometer.observation.Observation.lowCardinalityKeyValue.

Adds a low cardinality key value.
public Observation
lowCardinalityKeyValue(String
key
key
,
String
value
value
)

Overrides default io.micrometer.observation.Observation.lowCardinalityKeyValue.

Adds a low cardinality key value.
public Observation
observationConvention(ObservationConvention<?>
observation convention
observationConvention
)

Implements io.micrometer.observation.Observation.observationConvention.

Sets an observation convention that can be used to attach key values to the observation.
public Observation.Scope
openScope()

Implements io.micrometer.observation.Observation.openScope.

When put in scope, additional operations can take place by the ObservationHandlers such as putting entries in thread local.
public Observation
parentObservation(Observation
parent observation to set
parentObservation
)

Implements io.micrometer.observation.Observation.parentObservation.

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.
public Observation
start()

Implements io.micrometer.observation.Observation.start.

Starts the observation.
public void
stop()

Implements io.micrometer.observation.Observation.stop.

Stop the observation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONTEXTback to summary
private static final Observation.Context CONTEXT

Constructor Detail

NoopObservationback to summary
pack-priv NoopObservation()

Method Detail

contextualNameback to summary
public Observation contextualName(String contextualName)

Implements io.micrometer.observation.Observation.contextualName.

Doc from io.micrometer.observation.Observation.contextualName.

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.

Parameters
contextualName:String

contextual name

Returns:Observation

this

Annotations
@Override
errorback to summary
public Observation error(Throwable error)

Implements io.micrometer.observation.Observation.error.

Doc from io.micrometer.observation.Observation.error.

Signals an error.

Parameters
error:Throwable

error

Returns:Observation

this

Annotations
@Override
eventback to summary
public Observation event(Observation.Event event)

Implements io.micrometer.observation.Observation.event.

Doc from io.micrometer.observation.Observation.event.

Signals an arbitrary Event.

Parameters
event:Observation.Event

event

Returns:Observation

this

Annotations
@Override
getContextback to summary
public Observation.Context getContext()

Implements io.micrometer.observation.Observation.getContext.

Doc from io.micrometer.observation.Observation.getContext.

Returns the context attached to this observation.

Returns:Observation.Context

corresponding context

Annotations
@Override
highCardinalityKeyValueback to summary
public Observation highCardinalityKeyValue(KeyValue keyValue)

Implements io.micrometer.observation.Observation.highCardinalityKeyValue.

Doc from io.micrometer.observation.Observation.highCardinalityKeyValue.

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.).

Parameters
keyValue:KeyValue

key value

Returns:Observation

this

Annotations
@Override
highCardinalityKeyValueback to summary
public Observation highCardinalityKeyValue(String key, String value)

Overrides default io.micrometer.observation.Observation.highCardinalityKeyValue.

Doc from io.micrometer.observation.Observation.highCardinalityKeyValue.

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.).

Parameters
key:String

key

value:String

value

Returns:Observation

this

Annotations
@Override
lowCardinalityKeyValueback to summary
public Observation lowCardinalityKeyValue(KeyValue keyValue)

Implements io.micrometer.observation.Observation.lowCardinalityKeyValue.

Doc from io.micrometer.observation.Observation.lowCardinalityKeyValue.

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}).

Parameters
keyValue:KeyValue

key value

Returns:Observation

this

Annotations
@Override
lowCardinalityKeyValueback to summary
public Observation lowCardinalityKeyValue(String key, String value)

Overrides default io.micrometer.observation.Observation.lowCardinalityKeyValue.

Doc from io.micrometer.observation.Observation.lowCardinalityKeyValue.

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}).

Parameters
key:String

key

value:String

value

Returns:Observation

this

Annotations
@Override
observationConventionback to summary
public Observation observationConvention(ObservationConvention<?> observationConvention)

Implements io.micrometer.observation.Observation.observationConvention.

Doc from io.micrometer.observation.Observation.observationConvention.

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 Context.

Warning

You must set the ObservationConvention to the Observation before it is started.

Parameters
observationConvention:ObservationConvention<?>

observation convention

Returns:Observation

this

Annotations
@Override
openScopeback to summary
public Observation.Scope openScope()

Implements io.micrometer.observation.Observation.openScope.

Doc from io.micrometer.observation.Observation.openScope.

When put in scope, additional operations can take place by the ObservationHandlers such as putting entries in thread local.

Returns:Observation.Scope

new scope

Annotations
@Override
parentObservationback to summary
public Observation parentObservation(Observation parentObservation)

Implements io.micrometer.observation.Observation.parentObservation.

Doc from io.micrometer.observation.Observation.parentObservation.

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 openScope() method then the parent observation will be automatically set, and you don't have to call this method.

Parameters
parentObservation:Observation

parent observation to set

Returns:Observation

this

Annotations
@Override
startback to summary
public Observation start()

Implements io.micrometer.observation.Observation.start.

Doc from io.micrometer.observation.Observation.start.

Starts the observation. Remember to call this method, otherwise timing calculations will not take place.

Returns:Observation

this

Annotations
@Override
stopback to summary
public void stop()

Implements io.micrometer.observation.Observation.stop.

Doc from io.micrometer.observation.Observation.stop.

Stop the observation. Remember to call this method, otherwise timing calculations won't be finished.

Annotations
@Override
io.micrometer.observation back to summary

pack-priv final Class NoopObservation.NoopScope

extends Object
implements Scope
Class Inheritance
All Implemented Interfaces
io.micrometer.observation.Observation.Scope, java.lang.AutoCloseable

Scope that does nothing.

Field Summary

Modifier and TypeField and Description
pack-priv static final Observation.Scope
INSTANCE

Instance of NoopScope.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements io.micrometer.observation.Observation.Scope.close.

Clears the current scope and notifies the handlers that the scope was closed.
public Observation
getCurrentObservation()

Implements io.micrometer.observation.Observation.Scope.getCurrentObservation.

Current observation available within this scope.
public void
makeCurrent()

Implements io.micrometer.observation.Observation.Scope.makeCurrent.

This method assumes that all previous scopes got reset().
public void
reset()

Implements io.micrometer.observation.Observation.Scope.reset.

Resets the current scope.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
pack-priv static final Observation.Scope INSTANCE

Instance of NoopScope.

Constructor Detail

NoopScopeback to summary
private NoopScope()

Method Detail

closeback to summary
public void close()

Implements io.micrometer.observation.Observation.Scope.close.

Doc from io.micrometer.observation.Observation.Scope.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.

Annotations
@Override
getCurrentObservationback to summary
public Observation getCurrentObservation()

Implements io.micrometer.observation.Observation.Scope.getCurrentObservation.

Doc from io.micrometer.observation.Observation.Scope.getCurrentObservation.

Current observation available within this scope.

Returns:Observation

current observation that this scope was created by

Annotations
@Override
makeCurrentback to summary
public void makeCurrent()

Implements io.micrometer.observation.Observation.Scope.makeCurrent.

Doc from io.micrometer.observation.Observation.Scope.makeCurrent.

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.

Annotations
@Override
resetback to summary
public void reset()

Implements io.micrometer.observation.Observation.Scope.reset.

Doc from io.micrometer.observation.Observation.Scope.reset.

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.

Annotations
@Override