public class XRayTracer
extends org.apache.camel.support.ServiceSupport
implements org.apache.camel.spi.RoutePolicyFactory, org.apache.camel.StaticService, org.apache.camel.CamelContextAware
XRayTracer
in your Camel application.
This class uses a RoutePolicy
as well as a EventNotifier
internally to manage the creation and termination of AWS XRay
Segments
and Subsegments
once an exchange was created,
forwarded or closed in order to allow monitoring the lifetime metrics of the exchange.
A InterceptStrategy
is used in order to track invocations and durations of EIP patterns
used in processed routes. If no strategy is passed while configuration via setTracingStrategy(InterceptStrategy)
, a NoopTracingStrategy
will be used by default
which will not monitor any invocations at all.
By default every invoked route will be tracked by AWS XRay. If certain routes shell not be
tracked addExcludePattern(String)
and setExcludePatterns(Set)
can be used to
provide the routeId of the routes to exclude from monitoring.Modifier and Type | Field and Description |
---|---|
static String |
XRAY_TRACE_ID
Header value kept in the message of the exchange
|
Constructor and Description |
---|
XRayTracer() |
Modifier and Type | Method and Description |
---|---|
void |
addExcludePattern(String pattern)
Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern.
|
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() |
Set<String> |
getExcludePatterns()
Returns the set of currently excluded routes.
|
protected SegmentDecorator |
getSegmentDecorator(org.apache.camel.Endpoint endpoint) |
org.apache.camel.spi.InterceptStrategy |
getTracingStrategy()
Returns the currently used tracing strategy which is responsible for tracking invoked EIP or
beans.
|
void |
init(org.apache.camel.CamelContext camelContext)
Initializes this AWS XRay tracer implementation as service within the Camel environment.
|
static String |
sanitizeName(String name)
Removes invalid characters from AWS XRay (sub-)segment names and replaces the invalid characters with an
underscore character.
|
void |
setCamelContext(org.apache.camel.CamelContext camelContext) |
void |
setExcludePatterns(Set<String> excludePatterns)
Excludes all of the routes matching any of the contained routeIds within the given argument
from tracking by this tracer implementation.
|
void |
setTracingStrategy(org.apache.camel.spi.InterceptStrategy tracingStrategy)
Specifies the instance responsible for tracking invoked EIP and beans with AWS XRay.
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public static final String XRAY_TRACE_ID
public void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext
in interface org.apache.camel.CamelContextAware
public org.apache.camel.CamelContext getCamelContext()
getCamelContext
in interface org.apache.camel.CamelContextAware
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
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.ServiceSupport
Exception
protected void doStop() throws Exception
doStop
in class org.apache.camel.support.ServiceSupport
Exception
public void init(org.apache.camel.CamelContext camelContext)
camelContext
- The context to register this tracer as service withpublic org.apache.camel.spi.InterceptStrategy getTracingStrategy()
public void setTracingStrategy(org.apache.camel.spi.InterceptStrategy tracingStrategy)
tracingStrategy
- The instance which tracks invoked EIP and beanspublic Set<String> getExcludePatterns()
public void setExcludePatterns(Set<String> excludePatterns)
excludePatterns
- A set of routeIds which should not be tracked by this tracerpublic void addExcludePattern(String pattern)
pattern
- The pattern such as route id, endpoint urlprotected SegmentDecorator getSegmentDecorator(org.apache.camel.Endpoint endpoint)
public static String sanitizeName(String name)
name
- The name to assign to an AWS XRay (sub-)segmentApache Camel