davsclaus commented on code in PR #25444:
URL: https://github.com/apache/camel/pull/25444#discussion_r3758834260
##########
components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/eventnotifier/AbstractMicrometerEventNotifier.java:
##########
@@ -41,6 +41,7 @@ public abstract class AbstractMicrometerEventNotifier<T
extends CamelEvent> exte
private boolean skipCamelInfo = false;
private boolean logMetricsOnShutdown = false;
private String logMetricsOnShutdownFilters[];
+ private String logMetricsOnShutdownFormat;
Review Comment:
This field defaults to `null`, but `doStart()` unconditionally passes it to
`registryService.setLogMetricsOnShutdownFormat(...)`, which overwrites the
service's `"json"` default with `null` when the notifier is used standalone
(without `MicrometerPrometheus`). The code still *behaves* correctly because
`"prometheus".equalsIgnoreCase(null)` is false, but a
`getLogMetricsOnShutdownFormat()` call on the service would return `null`
instead of the documented `"json"` default.
Note how `MicrometerPrometheus.doInit()` guards the setter with `if
(getLogMetricsOnShutdownFormat() != null)` — this class should be consistent.
```suggestion
private String logMetricsOnShutdownFormat = "json";
```
##########
components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/json/AbstractMicrometerServicePrometheusFormatTest.java:
##########
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.micrometer.json;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import io.micrometer.core.instrument.Counter;
+import io.micrometer.core.instrument.DistributionSummary;
+import io.micrometer.core.instrument.FunctionCounter;
+import io.micrometer.core.instrument.FunctionTimer;
+import io.micrometer.core.instrument.Gauge;
+import io.micrometer.core.instrument.LongTaskTimer;
+import io.micrometer.core.instrument.Meter;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.instrument.Timer;
+import org.junit.jupiter.api.Test;
Review Comment:
Per project conventions, new test code should prefer AssertJ assertions
(`assertThat(...)`) over JUnit assertions (`assertEquals`, `assertTrue`).
AssertJ is already available as a test dependency.
For example:
```java
import static org.assertj.core.api.Assertions.assertThat;
assertThat(lines.get(0)).isEqualTo("# HELP app_info Application info");
assertThat(lines).hasSize(3);
assertThat(lines.get(2)).endsWith(" NaN");
assertThat(valueLine).startsWith("app_info{").contains("camel_version=\"4.0.0\"");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]