Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public static void configureMain(CamelContext camelContext, String profile, Main
if (!enabled) {
config.tracerConfig().withStandby(true);
}
if (!config.isTracing()) {
config.setTracingStandby(true);
}
}

if ("dev".equals(profile)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* 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.main;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spi.Tracer;
import org.junit.jupiter.api.Test;

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

public class MainDevProfileTracingStandbyTest {

@Test
public void testDevProfileEnablesTracingStandby() {
Main main = new Main();
main.configure().withProfile("dev");

main.start();
try {
CamelContext context = main.getCamelContext();
assertTrue(context.isTracingStandby(),
"dev profile should enable tracing standby");
} finally {
main.stop();
}
}

@Test
public void testDevProfileTracingCanBeEnabledAtRuntime() throws Exception {
Main main = new Main();
main.configure().withProfile("dev");
main.configure().addRoutesBuilder(new RouteBuilder() {
@Override
public void configure() {
from("direct:start").to("mock:result");
}
});

main.start();
try {
CamelContext context = main.getCamelContext();
Tracer tracer = context.getTracer();
assertFalse(tracer.isEnabled(),
"tracer should be in standby (not enabled) by default in dev mode");

tracer.setEnabled(true);
assertTrue(tracer.isEnabled(),
"tracer should be enableable at runtime in dev mode");
} finally {
main.stop();
}
}

@Test
public void testProdProfileDoesNotEnableTracingStandby() {
Main main = new Main();
main.configure().withProfile("prod");

main.start();
try {
CamelContext context = main.getCamelContext();
assertFalse(context.isTracingStandby(),
"prod profile should not enable tracing standby");
} finally {
main.stop();
}
}

}
3 changes: 3 additions & 0 deletions docs/user-manual/modules/ROOT/pages/tracer.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ camel.main.tracing = true
By default, Camel optimizes and opt-out tracing. Therefore, you would either have to enable tracing from the startup,
or turn on standby mode, to allow tracing to be enabled later during runtime.

NOTE: When using Camel Main or Camel JBang with the `dev` profile (the default), tracing standby is automatically enabled.
This means you can toggle tracing on and off at runtime without needing to restart.

To set tracing in standby mode you can do:

[tabs]
Expand Down