Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Option

Default

Description

formatter

 

Sets the Trace Formatter to use. Will default use org.apache.camel.processor.interceptor.DefaultTraceFormatter.

enabled

true

Flag to enable or disable this tracer

logLevel

INFO

The logging level to use: FATAL, ERROR, WARN, INFO, DEBUG, TRACE

logName

 

The log name to use. Will default use org.apache.camel.processor.interceptor.TraceInterceptor.

traceFilter

null

An exchange Predicate to filter the tracing.

traceInterceptors

false

Flag to enable or disable tracing of interceptors

traceExceptions

true

Flag to enable or disable tracing of thrown exception during processing of the exchange

destinationUri

null

Camel 2.0: Optional destination uri to route TraceEventExchange containing TraceEventMessage with details about the trace. Can be used for custom processing to store traces in database using JPA.

...

Wiki Markup
{snippet:id=e1|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java}

...

You can see this in action with the SpringTraceTest and its spring.xml file

Another option is to just include a spring XML which defines the Tracer bean such as the one that is automatically included if you run the Main with -t above.

Configuration from Spring

...

Wiki Markup
{snippet:id=e1|lang=xml|url=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/tracerConfigurationTest.xml}

...

Wiki Markup
{snippet:id=e1|lang=xml|url=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/traceFormatterTest.xml}

...

Wiki Markup
{snippet:id=tracingOutExchanges|title=Java DSL|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorWithOutBodyTraceTest.java}

...

Wiki Markup
{snippet:id=tracingOutExchanges|title=Spring DSL|lang=xml|url=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/traceInterceptorWithOutBodyTrace.xml}

...

Wiki Markup
{snippet:id=e1|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceFormatterTest.java}

...

Wiki Markup
{snippet:id=e2|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceFormatterTest.java}

...

This works by Camel creates a new TraceEventExchange containing:

  • snapshot of the original traced Exchange as a immutable TraceEventMessage containing String values of the fields, when the interception occurred. This ensures the fields contains the exact data at the given time of interception.
  • the original Exchange can be accessed using getTracedExchange()
Warning

Beware to access the original Exchange to avoid causing any side effects or alter its state. Prefer to access the information from TraceEventMessage

Camel routes the TraceEventExchange synchronously from the point of interception. When its completed Camel will continue routing the original Exchange.

...

Wiki Markup
{snippet:id=e1|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorDestinationTest.java}

...

Wiki Markup
{snippet:id=e2|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorDestinationTest.java}

...