Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micrometer: Router policy should be disabled by default #5028 #5247

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/modules/ROOT/pages/migration-guide/3.0.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ The following extensions have been removed.
| camel-quarkus-vm | camel-quarkus-seda
| camel-quarkus-xstream | camel-quarkus-jacksonxml
|===


== Change to default values of `camel.metrics.enableRoutePolicy` configuration

The Micrometer extension's route policy was enabled by default in previous releases.

Current behaviour has changed to reflect the default behavior of Camel.
`MicrometerRoutePolicyFactory` is now disabled by default.

You can enable `MicrometerRoutePolicyFactory` using configuration property.

```
quarkus.camel.metrics.enable-route-policy = true
```

For more information, refer to the xref:reference/extensions/micrometer.adoc[Camel Quarkus Micrometer Extension] documentation.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ get created for you.

Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.
| `boolean`
| `true`
| `false`

|icon:lock[title=Fixed at build time] [[quarkus.camel.metrics.enable-message-history]]`link:#quarkus.camel.metrics.enable-message-history[quarkus.camel.metrics.enable-message-history]`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.quarkus.test.QuarkusUnitTest;
import jakarta.inject.Inject;
import org.apache.camel.CamelContext;
import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
import org.apache.camel.component.micrometer.spi.InstrumentedThreadPoolFactory;
import org.apache.camel.impl.engine.DefaultMessageHistoryFactory;
import org.apache.camel.spi.EventNotifier;
Expand Down Expand Up @@ -51,8 +50,7 @@ public class MicrometerMetricsConfigDefaultsTest {
@Test
public void testMicrometerMetricsConfiguration() {
List<RoutePolicyFactory> routePolicyFactories = context.getRoutePolicyFactories();
assertEquals(1, routePolicyFactories.size());
assertTrue(routePolicyFactories.get(0) instanceof MicrometerRoutePolicyFactory);
assertEquals(0, routePolicyFactories.size());

MessageHistoryFactory messageHistoryFactory = context.getMessageHistoryFactory();
assertNotNull(messageHistoryFactory);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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.quarkus.component.micrometer.deployment;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
import java.util.Properties;

import io.quarkus.test.QuarkusUnitTest;
import jakarta.inject.Inject;
import org.apache.camel.CamelContext;
import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
import org.apache.camel.spi.RoutePolicyFactory;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class MicrometerMetricsConfigRoutePolicyTest {

@RegisterExtension
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addAsResource(applicationProperties(), "application.properties"));

@Inject
CamelContext context;

@Test
public void testRouteConfigEnabledConfiguration() {
List<RoutePolicyFactory> routePolicyFactories = context.getRoutePolicyFactories();
assertEquals(1, routePolicyFactories.size());
assertTrue(routePolicyFactories.get(0) instanceof MicrometerRoutePolicyFactory);
}

public static final Asset applicationProperties() {
Writer writer = new StringWriter();

Properties props = new Properties();
props.setProperty("quarkus.camel.metrics.enable-route-policy", "true");

try {
props.store(writer, "");
} catch (IOException e) {
throw new RuntimeException(e);
}

return new StringAsset(writer.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class CamelMicrometerConfig {
* Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics
* on route processing times.
*/
@ConfigItem(defaultValue = "true")
@ConfigItem(defaultValue = "false")
public boolean enableRoutePolicy;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ camel.context.name = quarkus-camel-micrometer

quarkus.camel.metrics.enable-message-history = true

quarkus.camel.metrics.enable-instrumented-thread-pool-factory = true
quarkus.camel.metrics.enable-instrumented-thread-pool-factory = true

quarkus.camel.metrics.enable-route-policy = true