Skip to content

Commit ce36bf0

Browse files
authored
Consistently mark ObservationRegistry parameters not null (micrometer-metrics#3451)
There should be no need for users to pass a `null` registry because we provide the no-op registry as a default value. It can also be used to make instrumentation a no-op.
1 parent 036b40e commit ce36bf0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

micrometer-observation/src/main/java/io/micrometer/observation/Observation.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static Observation start(String name, ObservationRegistry registry) {
7878
* @return started observation
7979
*/
8080
static <T extends Context> Observation start(String name, Supplier<T> contextSupplier,
81-
@Nullable ObservationRegistry registry) {
81+
ObservationRegistry registry) {
8282
return createNotStarted(name, contextSupplier, registry).start();
8383
}
8484

@@ -91,7 +91,7 @@ static <T extends Context> Observation start(String name, Supplier<T> contextSup
9191
* @param registry observation registry
9292
* @return created but not started observation
9393
*/
94-
static Observation createNotStarted(String name, @Nullable ObservationRegistry registry) {
94+
static Observation createNotStarted(String name, ObservationRegistry registry) {
9595
return createNotStarted(name, Context::new, registry);
9696
}
9797

@@ -113,7 +113,7 @@ static Observation createNotStarted(String name, @Nullable ObservationRegistry r
113113
* @return created but not started observation
114114
*/
115115
static <T extends Context> Observation createNotStarted(String name, Supplier<T> contextSupplier,
116-
@Nullable ObservationRegistry registry) {
116+
ObservationRegistry registry) {
117117
if (registry == null || registry.isNoop()) {
118118
return NOOP;
119119
}
@@ -175,8 +175,7 @@ static <T extends Context> Observation createNotStarted(@Nullable ObservationCon
175175
* @param registry observation registry
176176
* @return started observation
177177
*/
178-
static Observation start(ObservationConvention<Context> observationConvention,
179-
@Nullable ObservationRegistry registry) {
178+
static Observation start(ObservationConvention<Context> observationConvention, ObservationRegistry registry) {
180179
return start(observationConvention, Context::new, registry);
181180
}
182181

@@ -197,7 +196,7 @@ static Observation start(ObservationConvention<Context> observationConvention,
197196
* @return started observation
198197
*/
199198
static <T extends Context> Observation start(ObservationConvention<T> observationConvention,
200-
Supplier<T> contextSupplier, @Nullable ObservationRegistry registry) {
199+
Supplier<T> contextSupplier, ObservationRegistry registry) {
201200
return createNotStarted(observationConvention, contextSupplier, registry).start();
202201
}
203202

@@ -238,7 +237,7 @@ static <T extends Context> Observation start(@Nullable ObservationConvention<T>
238237
* @return created but not started observation
239238
*/
240239
static Observation createNotStarted(ObservationConvention<Context> observationConvention,
241-
@Nullable ObservationRegistry registry) {
240+
ObservationRegistry registry) {
242241
return createNotStarted(observationConvention, Context::new, registry);
243242
}
244243

@@ -269,7 +268,7 @@ static Observation createNotStarted(ObservationConvention<Context> observationCo
269268
* @return created but not started observation
270269
*/
271270
static <T extends Context> Observation createNotStarted(ObservationConvention<T> observationConvention,
272-
Supplier<T> contextSupplier, @Nullable ObservationRegistry registry) {
271+
Supplier<T> contextSupplier, ObservationRegistry registry) {
273272
if (registry == null || registry.isNoop() || observationConvention == NoopObservationConvention.INSTANCE) {
274273
return NOOP;
275274
}

0 commit comments

Comments
 (0)