@@ -127,6 +127,7 @@ static <T extends Context> Observation createNotStarted(String name, Supplier<T>
127127 return new SimpleObservation (name , registry , context == null ? new Context () : context );
128128 }
129129
130+ // @formatter:off
130131 /**
131132 * Creates but <b>does not start</b> an {@link Observation}. Remember to call
132133 * {@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>
143144 * {@link ObservationRegistry.ObservationConfig#getObservationConvention(Context, ObservationConvention)})
144145 * was found. The {@link ObservationConvention} implementation can override
145146 * {@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>
146168 * @param <T> type of context
147169 * @param customConvention custom convention. If {@code null}, the default one will be
148170 * picked.
149171 * @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
151173 * @param contextSupplier supplier for the observation context
152174 * @param registry observation registry
153175 * @return created but not started observation
154176 */
177+ // @formatter:on
155178 static <T extends Context > Observation createNotStarted (@ Nullable ObservationConvention <T > customConvention ,
156179 ObservationConvention <T > defaultConvention , Supplier <T > contextSupplier , ObservationRegistry registry ) {
157180 if (registry .isNoop ()) {
@@ -174,6 +197,11 @@ static <T extends Context> Observation createNotStarted(@Nullable ObservationCon
174197 /**
175198 * Creates and starts an {@link Observation}. When no registry is passed or
176199 * 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>
177205 * @param observationConvention observation convention
178206 * @param registry observation registry
179207 * @return started observation
@@ -192,6 +220,11 @@ static Observation start(ObservationConvention<Context> observationConvention, O
192220 * {@link ObservationRegistry.ObservationConfig#observationPredicate(ObservationPredicate)
193221 * ObservationConfig#observationPredicate}), a no-op observation will also be
194222 * 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>
195228 * @param <T> type of context
196229 * @param observationConvention observation convention
197230 * @param contextSupplier mutable context supplier
@@ -216,6 +249,11 @@ static <T extends Context> Observation start(ObservationConvention<T> observatio
216249 * provide a default one if neither a custom nor a pre-configured one (via
217250 * {@link ObservationRegistry.ObservationConfig#getObservationConvention(Context, ObservationConvention)})
218251 * 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>
219257 * @param <T> type of context
220258 * @param registry observation registry
221259 * @param contextSupplier the observation context supplier
@@ -235,6 +273,11 @@ static <T extends Context> Observation start(@Nullable ObservationConvention<T>
235273 * {@link Observation#start()} when you want the measurements to start. When no
236274 * registry is passed or observation is not applicable will return a no-op
237275 * 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>
238281 * @param observationConvention observation convention
239282 * @param registry observation registry
240283 * @return created but not started observation
@@ -265,6 +308,11 @@ static Observation createNotStarted(ObservationConvention<Context> observationCo
265308 * of {@link Context} to be passed and if you're not providing one we won't be able to
266309 * initialize it ourselves.
267310 * </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>
268316 * @param <T> type of context
269317 * @param observationConvention observation convention
270318 * @param contextSupplier mutable context supplier
@@ -380,8 +428,8 @@ default boolean isNoop() {
380428
381429 /**
382430 * 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.
385433 * @param observationConvention observation convention
386434 * @return this
387435 */
0 commit comments