Interface Tracer

All Superinterfaces:
AutoCloseable, Service, StaticService

public interface Tracer extends StaticService
SPI for intercepting Exchange flow at each EIP node in a route for tracing and debugging purposes.

The tracer hooks into the routing pipeline at every NamedNode EIP and fires traceBeforeNode(NamedNode, Exchange)/traceAfterNode(NamedNode, Exchange) around each step, plus traceBeforeRoute(NamedRoute, Exchange)/traceAfterRoute(NamedRoute, Exchange) for the route entry and exit. Two built-in implementations exist: BacklogTracer (buffered in-memory capture accessible via JMX or the developer console) and the OpenTelemetry tracer in camel-opentelemetry (exports spans to distributed tracing backends).

Tracers support a standby mode: when isStandby() is true the tracer is wired into the pipeline at startup but does not record anything until manually enabled, which avoids restart overhead when toggling tracing via JMX at runtime. The setTracePattern(String) and setTraceTemplates(boolean) options limit which nodes are traced to reduce verbosity.

See Tracer in the Camel user manual.

Since:
3.0
See Also:
  • Method Details

    • shouldTrace

      boolean shouldTrace(NamedNode definition)
      Whether or not to trace the given processor definition.
      Parameters:
      definition - the processor definition
      Returns:
      true to trace, false to skip tracing
    • traceBeforeRoute

      void traceBeforeRoute(NamedRoute route, Exchange exchange)
      Trace before the route (eg input to route)
      Parameters:
      route - the route EIP
      exchange - the exchange
    • traceBeforeNode

      void traceBeforeNode(NamedNode node, Exchange exchange)
      Trace before the given node
      Parameters:
      node - the node EIP
      exchange - the exchange
    • traceAfterNode

      void traceAfterNode(NamedNode node, Exchange exchange)
      Trace after the given node
      Parameters:
      node - the node EIP
      exchange - the exchange
    • traceSentNode

      void traceSentNode(NamedNode node, Exchange exchange, Endpoint endpoint, long elapsed)
      Trace when an Exchange was sent to a given endpoint
      Parameters:
      node - the node EIP
      exchange - the exchange
      endpoint - the endpoint the exchange was sent to
      elapsed - time in millis for sending the exchange
    • traceAfterRoute

      void traceAfterRoute(NamedRoute route, Exchange exchange)
      Trace after the route (eg output from route)
      Parameters:
      route - the route EIP
      exchange - the exchange
    • getTraceCounter

      long getTraceCounter()
      Number of traced messages
    • resetTraceCounter

      void resetTraceCounter()
      Reset trace counter
    • isEnabled

      boolean isEnabled()
      Whether the tracer is enabled
    • setEnabled

      void setEnabled(boolean enabled)
      Whether the tracer is enabled
    • isStandby

      boolean isStandby()
      Whether the tracer is standby.

      If a tracer is in standby then the tracer is activated during startup and are ready to be enabled manually via JMX or calling the enabled method.

    • setStandby

      void setStandby(boolean standby)
      Whether the tracer is standby.

      If a tracer is in standby then the tracer is activated during startup and are ready to be enabled manually via JMX or calling the enabled method.

    • isTraceRests

      boolean isTraceRests()
      Whether to trace routes that is created from Rest DSL.
    • setTraceRests

      void setTraceRests(boolean traceRests)
      Whether to trace routes that is created from route templates or kamelets.
    • isTraceTemplates

      boolean isTraceTemplates()
      Whether tracing should trace inner details from route templates (or kamelets). Turning this off can reduce the verbosity of tracing when using many route templates, and allow to focus on tracing your own Camel routes only.
    • setTraceTemplates

      void setTraceTemplates(boolean traceTemplates)
      Whether tracing should trace inner details from route templates (or kamelets). Turning this off can reduce the verbosity of tracing when using many route templates, and allow to focus on tracing your own Camel routes only.
    • getTracePattern

      @Nullable String getTracePattern()
      Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to*. The pattern matches by node and route id's Multiple patterns can be separated by comma.
    • setTracePattern

      void setTracePattern(@Nullable String tracePattern)
      Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to*. The pattern matches by node and route id's Multiple patterns can be separated by comma.
    • isTraceBeforeAndAfterRoute

      boolean isTraceBeforeAndAfterRoute()
      Whether to include tracing of before/after routes to trace the input and responses of routes.
    • setTraceBeforeAndAfterRoute

      void setTraceBeforeAndAfterRoute(boolean traceBeforeAndAfterRoute)
      Whether to include tracing of before/after routes to trace the input and responses of routes.
    • getExchangeFormatter

      ExchangeFormatter getExchangeFormatter()
      To use a custom exchange formatter for formatting the output of the Exchange in the trace logs.
    • setExchangeFormatter

      void setExchangeFormatter(ExchangeFormatter exchangeFormatter)
      To use a custom exchange formatter for formatting the output of the Exchange in the trace logs.