@@ -127,6 +127,7 @@ static <T extends Context> Observation createNotStarted(String name, Supplier<T>
127
127
return new SimpleObservation (name , registry , context == null ? new Context () : context );
128
128
}
129
129
130
+ // @formatter:off
130
131
/**
131
132
* Creates but <b>does not start</b> an {@link Observation}. Remember to call
132
133
* {@link Observation#start()} when you want the measurements to start. When the
@@ -143,15 +144,37 @@ static <T extends Context> Observation createNotStarted(String name, Supplier<T>
143
144
* {@link ObservationRegistry.ObservationConfig#getObservationConvention(Context, ObservationConvention)})
144
145
* was found. The {@link ObservationConvention} implementation can override
145
146
* {@link Observation} names (i.e. name and contextual name) and key values.
147
+ * <pre>
148
+ * Here you can find the matrix of choosing the convention:
149
+ * 1. custom default no pre-configured -> custom
150
+ * 2. custom default pre-configured -> custom (not a valid case, just use custom)
151
+ * 3. no custom default no pre-configured -> default
152
+ * 4. no custom default pre-configured -> pre-configured
153
+ * 5. custom no default no pre-configured -> custom (providing default is recommended)
154
+ * 6. custom no default pre-configured -> custom (providing default is recommended)
155
+ * 7. no custom no default no pre-configured -> local names/tags will be used
156
+ * 8. no custom no default pre-configured -> pre-configured
157
+ * </pre>
158
+ * <p>
159
+ * Also, if you set a convention using,
160
+ * {@link Observation#observationConvention(ObservationConvention)} (not recommended),
161
+ * the convention you set here will be used and everything else (custom, default,
162
+ * pre-configured) will be ignored.
163
+ * </p>
164
+ * <p>
165
+ * If you want to add to the all the contexts or mutate them,
166
+ * use the ObservationFilter (e.g.: add region=cloud-1 or remove PII).
167
+ * </p>
146
168
* @param <T> type of context
147
169
* @param customConvention custom convention. If {@code null}, the default one will be
148
170
* picked.
149
171
* @param defaultConvention default convention when no custom convention was passed,
150
- * nor a configured one was found
172
+ * nor a pre- configured one was found
151
173
* @param contextSupplier supplier for the observation context
152
174
* @param registry observation registry
153
175
* @return created but not started observation
154
176
*/
177
+ // @formatter:on
155
178
static <T extends Context > Observation createNotStarted (@ Nullable ObservationConvention <T > customConvention ,
156
179
ObservationConvention <T > defaultConvention , Supplier <T > contextSupplier , ObservationRegistry registry ) {
157
180
if (registry .isNoop ()) {
@@ -174,6 +197,11 @@ static <T extends Context> Observation createNotStarted(@Nullable ObservationCon
174
197
/**
175
198
* Creates and starts an {@link Observation}. When no registry is passed or
176
199
* observation is not applicable will return a no-op observation.
200
+ * <p>
201
+ * Please check the javadoc of
202
+ * {@link Observation#createNotStarted(ObservationConvention, ObservationConvention, Supplier, ObservationRegistry)}
203
+ * method for the logic of choosing the convention.
204
+ * </p>
177
205
* @param observationConvention observation convention
178
206
* @param registry observation registry
179
207
* @return started observation
@@ -192,6 +220,11 @@ static Observation start(ObservationConvention<Context> observationConvention, O
192
220
* {@link ObservationRegistry.ObservationConfig#observationPredicate(ObservationPredicate)
193
221
* ObservationConfig#observationPredicate}), a no-op observation will also be
194
222
* returned.
223
+ * <p>
224
+ * Please check the javadoc of
225
+ * {@link Observation#createNotStarted(ObservationConvention, ObservationConvention, Supplier, ObservationRegistry)}
226
+ * method for the logic of choosing the convention.
227
+ * </p>
195
228
* @param <T> type of context
196
229
* @param observationConvention observation convention
197
230
* @param contextSupplier mutable context supplier
@@ -216,6 +249,11 @@ static <T extends Context> Observation start(ObservationConvention<T> observatio
216
249
* provide a default one if neither a custom nor a pre-configured one (via
217
250
* {@link ObservationRegistry.ObservationConfig#getObservationConvention(Context, ObservationConvention)})
218
251
* was found.
252
+ * <p>
253
+ * Please check the javadoc of
254
+ * {@link Observation#createNotStarted(ObservationConvention, ObservationConvention, Supplier, ObservationRegistry)}
255
+ * method for the logic of choosing the convention.
256
+ * </p>
219
257
* @param <T> type of context
220
258
* @param registry observation registry
221
259
* @param contextSupplier the observation context supplier
@@ -235,6 +273,11 @@ static <T extends Context> Observation start(@Nullable ObservationConvention<T>
235
273
* {@link Observation#start()} when you want the measurements to start. When no
236
274
* registry is passed or observation is not applicable will return a no-op
237
275
* observation.
276
+ * <p>
277
+ * Please check the javadoc of
278
+ * {@link Observation#createNotStarted(ObservationConvention, ObservationConvention, Supplier, ObservationRegistry)}
279
+ * method for the logic of choosing the convention.
280
+ * </p>
238
281
* @param observationConvention observation convention
239
282
* @param registry observation registry
240
283
* @return created but not started observation
@@ -265,6 +308,11 @@ static Observation createNotStarted(ObservationConvention<Context> observationCo
265
308
* of {@link Context} to be passed and if you're not providing one we won't be able to
266
309
* initialize it ourselves.
267
310
* </p>
311
+ * <p>
312
+ * Please check the javadoc of
313
+ * {@link Observation#createNotStarted(ObservationConvention, ObservationConvention, Supplier, ObservationRegistry)}
314
+ * method for the logic of choosing the convention.
315
+ * </p>
268
316
* @param <T> type of context
269
317
* @param observationConvention observation convention
270
318
* @param contextSupplier mutable context supplier
@@ -380,8 +428,8 @@ default boolean isNoop() {
380
428
381
429
/**
382
430
* Adds an observation convention that can be used to attach key values to the
383
- * observation. WARNING: You must add ObservationConvention instances to the
384
- * Observation before it is started.
431
+ * observation. WARNING: You must set the ObservationConvention to the Observation
432
+ * before it is started.
385
433
* @param observationConvention observation convention
386
434
* @return this
387
435
*/
0 commit comments