You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Available as of Camel 2.18

The camel-zipkin component is used for tracing and timing incoming and outgoing Camel messages using zipkin.

Events (span) are captured for incoming and outgoing messages being sent to/from Camel.

This means you need to configure which which Camel endpoints that maps to zipkin service names.

The mapping can be configured using:

  • route id - A Camel route id
  • endpoint url - A Camel endpoint url

For both kinds you can use wildcards and regular expressions to match, which is using the rules from Intercept.

To match all Camel messages you can use * in the pattern and configure that to the same service name.

If no mapping has been configured then Camel will fallback and use endpoint uri's as service names. 
However its recommended to configure service mappings so you can use human logic names instead of Camel endpoint uris in the names.

Camel will auto-configure a ScribeSpanCollector if no SpanCollector explicit has been configured, and if the hostname and port to the span collector has been configured as environment variables

  • ZIPKIN_COLLECTOR_SERVICE_HOST - The hostname
  • ZIPKIN_COLLECTOR_SERVICE_PORT - The port number

This makes it easy to use camel-zipkin in container platforms where the platform can run your application in a linux container where service configurations are provided as environment variables.

Options

You can configure the following options on ZipkinEventNotifier

OptionDefaultDescription
rate1.0fConfigures a rate that decides how many events should be traced by zipkin.
The rate is expressed as a percentage (1.0f = 100%, 0.5f is 50%, 0.1f is 10%).
spanCollector The collector to use for sending zipkin span events to the zipkin server.
serviceName To use a global service name that matches all Camel events
serviceMappings 

Sets the service mappings that matches Camel events to the given zipkin service name.
The content is a Map<String, String> where the key is a pattern and the value is the service name.
The pattern uses the rules from Intercept.

excludePatterns 

Sets exclude pattern(s) that will disable tracing with zipkin for Camel messages that matches the pattern.
The content is a Set<String> where the key is a pattern. The pattern uses the rules from Intercept.

includeMessageBodyfalseWhether to include the Camel message body in the zipkin traces.
This is not recommended for production usage, or when having big payloads. You can limit the size by configuring the max debug log size

Example

To enable camel-zipkin you need to configure first

ZipkinEventNotifier zipkin = new ZipkinEventNotifier();
// configure the scribe span collector with the hostname and port for the Zipkin Collector Server 
zipkin.setSpanCollector(new ScribeSpanCollector("192.168.90.100, 9410);
// and then add zipkin as event notifier
camelContext.getManagementStrategy().addEventNotifier(zipkin);

The configuration about will the trace all incoming and outgoing messages in Camel routes. 

However if you want to map Camel endpoints to human friendly logical names, you can add mappings such as:

zipkin.addServiceMapping("activemq:queue:invoice", "invoices");
zipkin.addServiceMapping("http:legacy.server.com*", "old-junk");

camel-zipin-starter

If you are using Spring Boot then you can add the camel-zipkin-starter dependency, and turn on zipkin by annotating the main class with @CamelZipkin. You can then configure camel-zipkin in the application.properties file where you can configure the hostname and port number for the Zipkin Server, and all the other options as listed in the options table above.

You can find an example of this in the camel-example-zipkin

  • No labels