You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* <<micrometer-observation-predicates-filters, Observation Predicates and Filters>>
11
+
12
+
*Micrometer Observation basic flow*
13
+
14
+
`Observation` through `ObservationRegistry` gets created with a mutable `Observation.Context`. On each Micrometer Observation lifecycle action (e.g. `start()`) a corresponding `ObservationHandler` method is called (e.g. `onStart`) with the mutable `Observation.Context` as argument.
`Observation` through `ObservationRegistry` gets created with a mutable `Observation.Context`. To allow name and key-value customization, an `ObservationConvention` can be used instead of direct name setting. List of `ObservationPredicate` is run to verify if an `Observation` should be created instead of a no-op version. On each Micrometer Observation lifecycle action (e.g. `start()`) a corresponding `ObservationHandler` method is called (e.g. `onStart`) with the mutable `Observation.Context` as argument. On `Observation` stop, before calling the `ObservationHandler` `onStop` methods, list of `ObservationFilter` is called to optionally further modify the `Observation.Context`.
59
+
60
+
[[micrometer-observation-context]]
61
+
== Observation.Context
62
+
63
+
To pass information between the instrumented code and the handler (or between handler methods, such as `onStart` and `onStop`), you can use an `Observation.Context`. An `Observation.Context` is a `Map`-like container that can store values for you while your handler can access the data inside the context.
64
+
1
65
[[micrometer-observation-handler]]
2
-
= Observation Handler
66
+
== Observation Handler
3
67
4
68
A popular way to record Observations is storing the start state in a `Timer.Sample` instance and stopping it when the event has ended.
Starting with Micrometer 1.10, you can register "handlers" (`ObservationHandler` instances) that are notified about the lifecycle event of an observation (for example, you can run custom code when an observation is started or stopped).
20
84
Using this feature lets you add tracing capabilities to your existing metrics instrumentation (see: `DefaultTracingObservationHandler`). The implementation of these handlers does not need to be tracing related. It is completely up to you how you are going to implement them (for example, you can add logging capabilities).
21
85
22
-
[[micrometer-observation-context]]
23
-
== Observation.Context
24
-
25
-
To pass information between the instrumented code and the handler (or between handler methods, such as `onStart` and `onStop`), you can use an `Observation.Context`. An `Observation.Context` is a `Map`-like container that can store values for you while your handler can access the data inside the context.
26
-
27
86
[[micrometer-observation-handler-example]]
28
-
== ObservationHandler Example
87
+
=== ObservationHandler Example
29
88
30
89
Based on this, we can implement a simple handler that lets the users know about its invocations by printing them out to `stdout`:
0 commit comments