...
The Tracer is an InterceptStrategy which can be applied to a DefaultCamelContext or SpringCamelContext to ensure that there is a TracerInterceptor created for every node in the DSL.
Formatting
The tracer formats the execution of exchanges to log lines. They are logged at INFO level in the log category: org.apache.camel.processor.interceptor.TraceInterceptor
.
The tracer uses by default TraceFormatter
to format the log line.
TraceFormatter has the following options
Option | Default | Description |
---|---|---|
showBreadCrumb | true | Outputs the unique unit of work for the exchange. To be used for correlation so you can identify the same exchange. |
showNode | true | The destination node. |
showExchangeId | false | To output the unique exchange id. Currently the breadcrumb is sufficient. |
showProperties | true | Output the exchange properties |
showHeaders | true | Output the in message headers |
showBody | true | Output the in body |
Example:
Code Block |
---|
ID-claus-acer/3690-1214458315718/2-0 -> node3 To[mock:a] InOnly Properties:{CamelCauseException=null} Headers:{to=James} Body:Hello London
|
ID-claus-acer/3690-1214458315718/2-0
is the breadcrumb with the unique correlation id.
node3
is the id of the node in the route path. Is always shown.
Toa
is the destination node.
InOnly
is the exchange pattern. Is always shown.
Then the rest is properties, headers and the body.
Enabling
To enable tracer from the main run
...
The tracer can be enabled by adding it to the interceptor chain to the camel context. This is demonstrated in the unit test below.
Notice: We could have changed the properties on the Tracer object before adding it, if we e.g. don't like the default settings.
TODO: snippet
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java} |
Running the test we get the trace information logged at INFO level:
Code Block |
---|
2008-06-26 07:31:55,828 [main ] INFO TraceInterceptor - ID-claus-acer/3690-1214458315718/2-0 -> node5 Interceptor[Delegate(Pipeline[DeadLetterChannel[Delegate(TraceInterceptor[Processor[MyProcessor]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]], DeadLetterChannel[Delegate(TraceInterceptor[To[mock:a]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]], DeadLetterChannel[Delegate(TraceInterceptor[To[mock:b]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]]])] InOnly Properties:{} Headers:{to=James} Body:Hello London
2008-06-26 07:31:55,843 [main ] INFO TraceInterceptor - ID-claus-acer/3690-1214458315718/2-0 -> node2 Processor[MyProcessor] InOnly Properties:{CamelCauseException=null} Headers:{to=James} Body:Hello London
2008-06-26 07:31:55,843 [main ] INFO TraceInterceptor - ID-claus-acer/3690-1214458315718/2-0 -> node3 To[mock:a] InOnly Properties:{CamelCauseException=null} Headers:{to=James} Body:Hello London
2008-06-26 07:31:55,843 [main ] INFO TraceInterceptor - ID-claus-acer/3690-1214458315718/2-0 -> node4 To[mock:b] InOnly Properties:{CamelCauseException=null} Headers:{to=James} Body:Hello London
2008-06-26 07:31:55,859 [main ] INFO TraceInterceptor - ID-claus-acer/3690-1214458315718/2-1 -> node5 Interceptor[Delegate(Pipeline[DeadLetterChannel[Delegate(TraceInterceptor[Processor[MyProcessor]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]], DeadLetterChannel[Delegate(TraceInterceptor[To[mock:a]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]], DeadLetterChannel[Delegate(TraceInterceptor[To[mock:b]]), RecipientList[log:org.apache.camel.DeadLetterChannel?level=error], RedeliveryPolicy[maximumRedeliveries=6]]])] InOnly Properties:{} Headers:{from=Claus} Body:This is Copenhagen calling
2008-06-26 07:31:55,859 [main ] INFO TraceInterceptor - ID-claus-acer/3690-1214458315718/2-1 -> node2 Processor[MyProcessor] InOnly Properties:{CamelCauseException=null} Headers:{from=Claus} Body:This is Copenhagen calling
2008-06-26 07:31:55,875 [main ] INFO TraceInterceptor - ID-claus-acer/3690-1214458315718/2-1 -> node3 To[mock:a] InOnly Properties:{CamelCauseException=null} Headers:{from=Claus} Body:This is Copenhagen calling
2008-06-26 07:31:55,875 [main ] INFO TraceInterceptor - ID-claus-acer/3690-1214458315718/2-1 -> node4 To[mock:b] InOnly Properties:{CamelCauseException=null} Headers:{from=Claus} Body:This is Copenhagen calling
|
Enabling from Spring XML
TODO: Spring XML
...