Skip to content

Commit fe36085

Browse files
authored
[docs] Improve observability docs for tap operator usage (#4009)
Added an explanation of where the `Observation` created by the `tap` operator is available. Also, moved down the `tap` operator in the example chain to properly align with scope of the `Observation`. Signed-off-by: Tadaya Tsuyukubo <[email protected]>
1 parent a8416f5 commit fe36085

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/modules/ROOT/pages/metrics.adoc

+7-7
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ A reactive chain can be observed via the `tap` operator and `Micrometer.observat
129129
----
130130
listenToEvents()
131131
.name("events") // <1>
132-
.tap(Micrometer.observation( // <2>
133-
applicationDefinedRegistry)) // <3>
134132
.doOnNext(event -> log.info("Received {}", event))
135133
.delayUntil(this::processEvent)
134+
.tap(Micrometer.observation( // <2>
135+
applicationDefinedRegistry)) // <3>
136136
.retry()
137137
.subscribe();
138138
----
139139
<1> The `Observation` for this pipeline will be identified with the "events" prefix.
140-
<2> We use the `tap` operator with the `observation` utility.
140+
<2> We use the `tap` operator with the `observation` utility, making an anonymous `observation` available to upstream operators.
141141
<3> A registry must be provided into which to publish the observation results. Note this is an `ObservationRegistry`.
142142

143143
The detail of the observation and its tags is provided in xref:metrics-details.adoc#micrometer-details-observation[Micrometer.observation()].
@@ -160,22 +160,22 @@ with your own Observation supplier, as follows:
160160
----
161161
listenToEvents()
162162
.name("events") // <1>
163+
.doOnNext(event -> log.info("Received {}", event))
164+
.delayUntil(this::processEvent)
163165
.tap(Micrometer.observation( // <2>
164166
applicationDefinedRegistry, // <3>
165167
registry -> Observation.createNotStarted( // <4>
166168
myConvention, // <5>
167169
myContextSupplier, // <6>
168170
registry)))
169-
.doOnNext(event -> log.info("Received {}", event))
170-
.delayUntil(this::processEvent)
171171
.retry()
172172
.subscribe();
173173
----
174174
<1> The `Observation` for this pipeline will be identified with the "events" prefix.
175-
<2> We use the `tap` operator with the `observation` utility.
175+
<2> We use the `tap` operator with the `observation` utility, making a custom `observation` available to upstream operators.
176176
<3> A registry must be provided into which to publish the observation results. Note this is an `ObservationRegistry`.
177177
<4> We provide our own function to create the Observation
178178
<5> with a custom `ObservationConvention`
179179
<6> and a custom `Supplier<Context>`.
180180

181-
include::metrics-details.adoc[levelOffset=1]
181+
include::metrics-details.adoc[levelOffset=1]

0 commit comments

Comments
 (0)