Package io.micrometer.observation
Interface Observation.ContextView
- All Known Implementing Classes:
Observation.Context
,ObservedAspect.ObservedAspectContext
,ReceiverContext
,RequestReplyReceiverContext
,RequestReplySenderContext
,SenderContext
- Enclosing interface:
Observation
public static interface Observation.ContextView
Read only view on the
Observation.Context
.-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object key) Checks if context contains a key.<T> T
Gets an entry from the context.io.micrometer.common.KeyValues
Returns all key values.Returns the contextual name.getError()
Error that occurred while processing theObservation
.io.micrometer.common.KeyValue
Returns a high cardinality key value ornull
if not present.io.micrometer.common.KeyValues
Returns high cardinality key values.io.micrometer.common.KeyValue
Returns a low cardinality key value ornull
if not present.io.micrometer.common.KeyValues
Returns low cardinality key values.getName()
The observation name.default <T> T
getOrDefault
(Object key, Supplier<T> defaultObjectSupplier) Returns an element or default if not present.<T> T
getOrDefault
(Object key, T defaultObject) Returns an element or default if not present.Returns the parentObservationView
.<T> T
getRequired
(Object key) Gets an entry from the context.
-
Method Details
-
getName
String getName()The observation name.- Returns:
- name
-
getContextualName
Returns the contextual name. The name that makes sense within the current context (e.g. name derived from HTTP request).- Returns:
- contextual name
-
getParentObservation
Returns the parentObservationView
.- Returns:
- parent observation or
null
if there was no parent
-
getError
Error that occurred while processing theObservation
.- Returns:
- error (null if there wasn't any)
-
get
Gets an entry from the context. Returnsnull
when entry is not present.- Type Parameters:
T
- value type- Parameters:
key
- key- Returns:
- entry or
null
if not present
-
getRequired
Gets an entry from the context. Throws exception when entry is not present.- Type Parameters:
T
- value type- Parameters:
key
- key- Returns:
- entry
- Throws:
IllegalArgumentException
- if not present
-
containsKey
Checks if context contains a key.- Parameters:
key
- key- Returns:
true
when the context contains the entry with the given key
-
getOrDefault
Returns an element or default if not present.- Type Parameters:
T
- value type- Parameters:
key
- keydefaultObject
- default object to return- Returns:
- object or default if not present
-
getOrDefault
Returns an element or default if not present.- Type Parameters:
T
- value type- Parameters:
key
- keydefaultObjectSupplier
- supplier for default object to return- Returns:
- object or default if not present
- Since:
- 1.11.0
-
getLowCardinalityKeyValues
io.micrometer.common.KeyValues getLowCardinalityKeyValues()Returns low cardinality key values.- Returns:
- low cardinality key values
-
getHighCardinalityKeyValues
@NonNull io.micrometer.common.KeyValues getHighCardinalityKeyValues()Returns high cardinality key values.- Returns:
- high cardinality key values
-
getLowCardinalityKeyValue
Returns a low cardinality key value ornull
if not present.- Parameters:
key
- key- Returns:
- a low cardinality key value or
null
-
getHighCardinalityKeyValue
Returns a high cardinality key value ornull
if not present.- Parameters:
key
- key- Returns:
- a high cardinality key value or
null
-
getAllKeyValues
@NonNull io.micrometer.common.KeyValues getAllKeyValues()Returns all key values.- Returns:
- all key values
-