Class ObservationThreadLocalAccessor
java.lang.Object
io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor
- All Implemented Interfaces:
io.micrometer.context.ThreadLocalAccessor<Observation>
public class ObservationThreadLocalAccessor
extends Object
implements io.micrometer.context.ThreadLocalAccessor<Observation>
A
ThreadLocalAccessor
to put and restore current Observation
.- Since:
- 1.10.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Key under which Micrometer Observation is being registered. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of this class and stores a static handle to it.ObservationThreadLocalAccessor
(ObservationRegistry observationRegistry) Creates a new instance of this class and stores a static handle to it. -
Method Summary
Modifier and TypeMethodDescriptionReturn the singleton instance of thisObservationThreadLocalAccessor
.Returns the providedObservationRegistry
.getValue()
key()
void
restore()
void
restore
(Observation value) void
setObservationRegistry
(ObservationRegistry observationRegistry) Provide anObservationRegistry
to be used byObservationThreadLocalAccessor
.void
setValue()
void
setValue
(Observation value) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micrometer.context.ThreadLocalAccessor
reset
-
Field Details
-
KEY
Key under which Micrometer Observation is being registered.- See Also:
-
instance
-
-
Constructor Details
-
ObservationThreadLocalAccessor
public ObservationThreadLocalAccessor()Creates a new instance of this class and stores a static handle to it. Remember to callContextRegistry.getInstance()
to load all accessors which will call this constructor. -
ObservationThreadLocalAccessor
Creates a new instance of this class and stores a static handle to it.- Parameters:
observationRegistry
- observation registry
-
-
Method Details
-
setObservationRegistry
Provide anObservationRegistry
to be used byObservationThreadLocalAccessor
.- Parameters:
observationRegistry
- observation registry
-
getObservationRegistry
Returns the providedObservationRegistry
.- Returns:
- observation registry
-
getInstance
Return the singleton instance of thisObservationThreadLocalAccessor
.- Returns:
- instance
-
key
- Specified by:
key
in interfaceio.micrometer.context.ThreadLocalAccessor<Observation>
-
getValue
- Specified by:
getValue
in interfaceio.micrometer.context.ThreadLocalAccessor<Observation>
-
setValue
- Specified by:
setValue
in interfaceio.micrometer.context.ThreadLocalAccessor<Observation>
-
setValue
public void setValue()- Specified by:
setValue
in interfaceio.micrometer.context.ThreadLocalAccessor<Observation>
-
restore
public void restore()- Specified by:
restore
in interfaceio.micrometer.context.ThreadLocalAccessor<Observation>
-
restore
- Specified by:
restore
in interfaceio.micrometer.context.ThreadLocalAccessor<Observation>
-