@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.
span reporter
one hasn't been explicitly configured,
and if the hostname and port to a zipkin 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() |
String |
getEndpoint() |
Set<String> |
getExcludePatterns() |
String |
getHostName() |
int |
getPort() |
float |
getRate() |
Map<String,String> |
getServerServiceMappings() |
String |
getServiceName() |
com.github.kristofa.brave.SpanCollector |
getSpanCollector()
Deprecated.
|
zipkin2.reporter.Reporter<zipkin2.Span> |
getSpanReporter()
Returns the reporter used to send timing data (spans) to the zipkin server.
|
void |
init(org.apache.camel.CamelContext camelContext)
Registers this
ZipkinTracer on the CamelContext if not already registered. |
boolean |
isIncludeMessageBody() |
boolean |
isIncludeMessageBodyStreams() |
void |
setCamelContext(org.apache.camel.CamelContext camelContext) |
void |
setClientServiceMappings(Map<String,String> clientServiceMappings) |
void |
setEndpoint(String endpoint)
Sets the POST URL for zipkin's v2 api, usually
"http://zipkinhost:9411/api/v2/spans"
|
void |
setExcludePatterns(Set<String> excludePatterns) |
void |
setHostName(String hostName)
Sets the hostname for the remote zipkin scribe collector.
|
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 scribe collector.
|
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)
Deprecated.
|
void |
setSpanReporter(zipkin2.reporter.Reporter<zipkin2.Span> spanReporter)
Sets the reporter used to send timing data (spans) 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
if not already registered.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 POST URL for zipkin\'s v2 api.") public String getEndpoint()
public void setEndpoint(String endpoint)
@ManagedAttribute(description="The hostname for the remote zipkin scribe collector.") public String getHostName()
public void setHostName(String hostName)
@ManagedAttribute(description="The port number for the remote zipkin scribe collector.") 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 traces@Deprecated public com.github.kristofa.brave.SpanCollector getSpanCollector()
getSpanReporter()
public void setSpanReporter(zipkin2.reporter.Reporter<zipkin2.Span> spanReporter)
public zipkin2.reporter.Reporter<zipkin2.Span> getSpanReporter()
@Deprecated public void setSpanCollector(com.github.kristofa.brave.SpanCollector spanCollector)
setSpanReporter(Reporter)
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