001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.spi;
018
019import org.apache.camel.Exchange;
020import org.apache.camel.NamedNode;
021import org.apache.camel.NamedRoute;
022import org.apache.camel.Route;
023import org.apache.camel.StaticService;
024
025/**
026 * SPI for tracing messages.
027 */
028public interface Tracer extends StaticService {
029
030    /**
031     * Whether or not to trace the given processor definition.
032     *
033     * @param definition the processor definition
034     * @return <tt>true</tt> to trace, <tt>false</tt> to skip tracing
035     */
036    boolean shouldTrace(NamedNode definition);
037
038    /**
039     * Trace before the route (eg input to route)
040     *
041     * @param route     the route
042     * @param exchange  the exchange
043     */
044    void traceBeforeRoute(NamedRoute route, Exchange exchange);
045
046    /**
047     * Trace before the given node
048     *
049     * @param node      the node EIP
050     * @param exchange  the exchange
051     */
052    void traceBeforeNode(NamedNode node, Exchange exchange);
053
054    /**
055     * Trace after the given node
056     *
057     * @param node      the node EIP
058     * @param exchange  the exchange
059     */
060    void traceAfterNode(NamedNode node, Exchange exchange);
061
062    /**
063     * Trace after the route (eg output from route)
064     *
065     * @param route     the route
066     * @param exchange  the exchange
067     */
068    void traceAfterRoute(Route route, Exchange exchange);
069
070    /**
071     * Number of traced messages
072     */
073    long getTraceCounter();
074
075    /**
076     * Reset trace counter
077     */
078    void resetTraceCounter();
079
080    /**
081     * Whether the tracer is enabled
082     */
083    boolean isEnabled();
084
085    /**
086     * Whether the tracer is enabled
087     */
088    void setEnabled(boolean enabled);
089
090    /**
091     * Tracing pattern to match which node EIPs to trace.
092     * For example to match all To EIP nodes, use to*.
093     * The pattern matches by node and route id's
094     * Multiple patterns can be separated by comma.
095     */
096    String getTracePattern();
097
098    /**
099     * Tracing pattern to match which node EIPs to trace.
100     * For example to match all To EIP nodes, use to*.
101     * The pattern matches by node and route id's
102     * Multiple patterns can be separated by comma.
103     */
104    void setTracePattern(String tracePattern);
105
106    /**
107     * Whether to include tracing of before/after routes to trace the input and responses of routes.
108     */
109    boolean isTraceBeforeAndAfterRoute();
110
111    /**
112     * Whether to include tracing of before/after routes to trace the input and responses of routes.
113     */
114    void setTraceBeforeAndAfterRoute(boolean traceBeforeAndAfterRoute);
115
116    /**
117     * To use a custom exchange formatter for formatting the output of the {@link Exchange} in the trace logs.
118     */
119    ExchangeFormatter getExchangeFormatter();
120
121    /**
122     * To use a custom exchange formatter for formatting the output of the {@link Exchange} in the trace logs.
123     */
124    void setExchangeFormatter(ExchangeFormatter exchangeFormatter);
125}




























































OSZAR »