@ManagedResource(description="ZipkinTracer")
public class ZipkinTracer
extends org.apache.camel.support.ServiceSupport
implements org.apache.camel.spi.RoutePolicyFactory, org.apache.camel.StaticService, org.apache.camel.CamelContextAware
ZipkinTracer
in your Camel application.
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
EndpointHelper.matchPattern(String, String)
and EndpointHelper.matchEndpoint(CamelContext, String, String)
To match all Camel messages you can use * in the pattern and configure that to the same service name.
ScribeSpanCollector
if no SpanCollector explicit has been configured, and
if the hostname and port to the span collector has been configured as environment variables
EventNotifier
and RoutePolicy
that allows
to trap when Camel starts/ends an Exchange
being routed using the RoutePolicy
and during the routing
if the Exchange
sends messages, then we track them using the EventNotifier
.Constructor and Description |
---|
ZipkinTracer() |
Modifier and Type | Method and Description |
---|---|
void |
addClientServiceMapping(String pattern,
String serviceName)
Adds a client service mapping that matches Camel events to the given zipkin service name.
|
void |
addExcludePattern(String pattern)
Adds an exclude pattern that will disable tracing with zipkin for Camel messages that matches the pattern.
|
void |
addServerServiceMapping(String pattern,
String serviceName)
Adds a server service mapping that matches Camel events to the given zipkin service name.
|
org.apache.camel.spi.RoutePolicy |
createRoutePolicy(org.apache.camel.CamelContext camelContext,
String routeId,
org.apache.camel.model.RouteDefinition route) |
protected void |
doStart() |
protected void |
doStop() |
org.apache.camel.CamelContext |
getCamelContext() |
Map<String,String> |
getClientServiceMappings() |
Set<String> |
getExcludePatterns() |
String |
getHostName() |
int |
getPort() |
float |
getRate() |
Map<String,String> |
getServerServiceMappings() |
String |
getServiceName() |
com.github.kristofa.brave.SpanCollector |
getSpanCollector() |
void |
init(org.apache.camel.CamelContext camelContext)
Registers this
ZipkinTracer on the CamelContext . |
boolean |
isIncludeMessageBody() |
boolean |
isIncludeMessageBodyStreams() |
void |
setCamelContext(org.apache.camel.CamelContext camelContext) |
void |
setClientServiceMappings(Map<String,String> clientServiceMappings) |
void |
setExcludePatterns(Set<String> excludePatterns) |
void |
setHostName(String hostName)
Sets a hostname for the remote zipkin server to use.
|
void |
setIncludeMessageBody(boolean includeMessageBody)
Whether to include the Camel message body in the zipkin traces.
|
void |
setIncludeMessageBodyStreams(boolean includeMessageBodyStreams)
Whether to include message bodies that are stream based in the zipkin traces.
|
void |
setPort(int port)
Sets the port number for the remote zipkin server to use.
|
void |
setRate(float rate)
Configures a rate that decides how many events should be traced by zipkin.
|
void |
setServerServiceMappings(Map<String,String> serverServiceMappings) |
void |
setServiceName(String serviceName)
To use a global service name that matches all Camel events
|
void |
setSpanCollector(com.github.kristofa.brave.SpanCollector spanCollector)
The collector to use for sending zipkin span events to the zipkin server.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public org.apache.camel.spi.RoutePolicy createRoutePolicy(org.apache.camel.CamelContext camelContext, String routeId, org.apache.camel.model.RouteDefinition route)
createRoutePolicy
in interface org.apache.camel.spi.RoutePolicyFactory
public void init(org.apache.camel.CamelContext camelContext)
ZipkinTracer
on the CamelContext
.public org.apache.camel.CamelContext getCamelContext()
getCamelContext
in interface org.apache.camel.CamelContextAware
public void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext
in interface org.apache.camel.CamelContextAware
@ManagedAttribute(description="The hostname for the remote zipkin server to use.") public String getHostName()
public void setHostName(String hostName)
@ManagedAttribute(description="The port number for the remote zipkin server to use.") public int getPort()
public void setPort(int port)
@ManagedAttribute(description="Rates 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%).") public float getRate()
public void setRate(float rate)
rate
- minimum sample rate is 0.0001, or 0.01% of tracespublic com.github.kristofa.brave.SpanCollector getSpanCollector()
public void setSpanCollector(com.github.kristofa.brave.SpanCollector spanCollector)
public String getServiceName()
public void setServiceName(String serviceName)
public void setClientServiceMappings(Map<String,String> clientServiceMappings)
public void addClientServiceMapping(String pattern, String serviceName)
pattern
- the pattern such as route id, endpoint urlserviceName
- the zipkin service namepublic void setServerServiceMappings(Map<String,String> serverServiceMappings)
public void addServerServiceMapping(String pattern, String serviceName)
pattern
- the pattern such as route id, endpoint urlserviceName
- the zipkin service namepublic void addExcludePattern(String pattern)
pattern
- the pattern such as route id, endpoint url@ManagedAttribute(description="Whether to include the Camel message body in the zipkin traces") public boolean isIncludeMessageBody()
@ManagedAttribute(description="Whether to include the Camel message body in the zipkin traces") public void setIncludeMessageBody(boolean includeMessageBody)
setIncludeMessageBodyStreams(boolean)
to
turn that on.@ManagedAttribute(description="Whether to include stream based Camel message bodies in the zipkin traces") public boolean isIncludeMessageBodyStreams()
@ManagedAttribute(description="Whether to include stream based Camel message bodies in the zipkin traces") public void setIncludeMessageBodyStreams(boolean includeMessageBodyStreams)
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.ServiceSupport
Exception
Apache Camel