You can set the traceFilter for tracer which is nothing but defining predicate.

Custom predicate can be defined as you want. It can be just one string or 
pattern of strings[destinations] you want to trace.

This is the solution I can think of in the current context.



Tracer tracer = new Tracer();

Predicate traceFilter = new RouteNamePredicate("direct://b");

tracer.setTraceFilter(traceFilter);


// Define new predicate like this. If true is returned then only tracing will 
be enabled.


public class RouteNamePredicate implements Predicate {

        String route;

        public RouteNamePredicate(String routeName) {
                this.route = routeName;
        }

        @Override
        public boolean matches(Exchange exchange) {
                String endPointUri =  
exchange.getFromEndpoint().getEndpointUri();

                if (route != null && route.equals(endPointUri)) {
                        return true;
                }
                return false;
        }


Hope this helps.

-----Original Message-----
From: Shing Hing Man [mailto:[email protected]]
Sent: Saturday, January 25, 2014 11:34 PM
To: [email protected]
Subject: Tracer per route without explicitly turning off tracing

Hi,

I am using Camel 2.12.1 .
I would like to  enable tracing for one route only.
The  example from

https://fisheye6.atlassian.com/browse/camel-git/camel-core/src/test/java/org/apache/camel/processor/TracePerRouteTest.java?r=2c295f02f7868cca60ed98a55b490083d2695a2a

shows how to enable tracing for route A, C only :

public void configure() throws Exception {

Tracer tracer = new Tracer();

tracer.setDestinationUri("mock:traced");

tracer.setLogName("foo");

context.addInterceptStrategy(tracer);

// route A
from("direct:a").to("mock:a");

// route B
from("direct:b").noTracing().to("mock:b");

// route C
from("direct:c").tracing().to("mock:c");

}


According to the above example, if I want to enable tracing for route X, say,  
the following steps are required.
1) Add a tracer to the context.
2) Enable tracing for route X.
3) Disable tracing (add noTracing) for other routes.


Is there a way of avoid adding noTracing to routes that requires no tracing, 
but still make tracing turn off for these routes ?
I only want tracing on route X.

Thanks in advance for any assistance!

Shing Hing Man
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful.

Reply via email to