Commit 76a8a12a authored by 吴晟's avatar 吴晟 Committed by GitHub
Browse files

Merge branch 'master' into feature/373

parents 34c5263a a04843a6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ Sky Walking | [中文](https://github.com/wu-sheng/sky-walking/wiki/sky-walking-
[![OpenTracing-1.0 Badge](https://img.shields.io/badge/OpenTracing--1.0-enabled-blue.svg)](http://opentracing.io)


* Auto-instrumentation mechanism, **no need to CHANGE any application source code**. [Supported middlewares, frameworks and libraries](https://github.com/wu-sheng/sky-walking/wiki/3.0-supported-list).
* Auto-instrumentation mechanism, **no need to CHANGE any application source code**. [Supported middlewares, frameworks and libraries](https://github.com/wu-sheng/sky-walking/wiki/3.1-supported-list).
* Explicit-instrumentation, as an [OpenTracing supported tracer](http://opentracing.io/documentation/pages/supported-tracers).
* Pure Java server implementation, with RESTful Web service.
* High performance streaming analysis.
@@ -26,7 +26,7 @@ _In chronological order_
* 张鑫 [**PMC Member**] [@ascrutae](https://github.com/ascrutae)   
* 谭真 [@mircoteam](https://github.com/mircoteam)  Advanced R&D Engineers, Creative & Interactive Group.
* 徐妍 [@TastySummer](https://github.com/TastySummer)
* 彭勇升 [**PMC Member**] [@pengys5](https://github.com/pengys5)   Technical Specialist, OneAPM.
* 彭勇升 [**PMC Member**] [@pengys5](https://github.com/pengys5) 
* 戴文
* 柏杨 [@bai-yang](https://github.com/bai-yang)  Senior Engineer, Alibaba Group.
* 陈凤 [@trey03](https://github.com/trey03)
+3 −1
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ public class KeyValuePair {
    public KeyWithStringValue transform() {
        KeyWithStringValue.Builder keyValueBuilder = KeyWithStringValue.newBuilder();
        keyValueBuilder.setKey(key);
        if (value != null) {
            keyValueBuilder.setValue(value);
        }
        return keyValueBuilder.build();
    }
}
+26 −0
Original line number Diff line number Diff line
package org.skywalking.apm.plugin.tomcat78x;

import java.lang.reflect.Method;
import org.skywalking.apm.agent.core.context.ContextManager;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;

public class TomcatExceptionInterceptor implements InstanceMethodsAroundInterceptor {
    @Override
    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
        MethodInterceptResult result) throws Throwable {
        ContextManager.activeSpan().errorOccurred().log((Throwable)allArguments[2]);
    }

    @Override
    public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
        Object ret) throws Throwable {
        return ret;
    }

    @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
        Class<?>[] argumentsTypes, Throwable t) {

    }
}
+2 −2
Original line number Diff line number Diff line
@@ -16,11 +16,11 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptR
import org.skywalking.apm.network.trace.component.ComponentsDefine;

/**
 * {@link TomcatInterceptor} fetch the serialized context data by using {@link HttpServletRequest#getHeader(String)}.
 * {@link TomcatInvokeInterceptor} fetch the serialized context data by using {@link HttpServletRequest#getHeader(String)}.
 * The {@link TraceSegment#refs} of current trace segment will reference to the trace
 * segment id of the previous level if the serialized context is not null.
 */
public class TomcatInterceptor implements InstanceMethodsAroundInterceptor {
public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor {

    /**
     * * The {@link TraceSegment#refs} of current trace segment will reference to the
+27 −7
Original line number Diff line number Diff line
@@ -8,14 +8,16 @@ import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoin
import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.skywalking.apm.plugin.tomcat78x.TomcatInterceptor;
import org.skywalking.apm.plugin.tomcat78x.TomcatInvokeInterceptor;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;

/**
 * {@link TomcatInstrumentation} presents that skywalking using class {@link TomcatInterceptor} to
 * intercept {@link org.apache.catalina.core.StandardEngineValve#invoke(Request, Response)}.
 * {@link TomcatInstrumentation} presents that skywalking using class {@link TomcatInvokeInterceptor} to intercept
 * {@link org.apache.catalina.core.StandardWrapperValve#invoke(Request, Response)} and using class {@link
 * org.skywalking.apm.plugin.tomcat78x.TomcatExceptionInterceptor} to intercept {@link
 * org.apache.catalina.core.StandardWrapperValve#exception(Request, Response, Throwable)}.
 *
 * @author zhangxin
 */
@@ -24,12 +26,17 @@ public class TomcatInstrumentation extends ClassInstanceMethodsEnhancePluginDefi
    /**
     * Enhance class.
     */
    private static final String ENHANCE_CLASS = "org.apache.catalina.core.StandardEngineValve";
    private static final String ENHANCE_CLASS = "org.apache.catalina.core.StandardWrapperValve";

    /**
     * Intercept class.
     * The intercept class for "invoke" method in the class "org.apache.catalina.core.StandardWrapperValve"
     */
    private static final String INTERCEPT_CLASS = "org.skywalking.apm.plugin.tomcat78x.TomcatInterceptor";
    private static final String INVOKE_INTERCEPT_CLASS = "org.skywalking.apm.plugin.tomcat78x.TomcatInvokeInterceptor";

    /**
     * The intercept class for "exception" method in the class "org.apache.catalina.core.StandardWrapperValve"
     */
    private static final String EXCEPTION_INTERCEPT_CLASS = "org.skywalking.apm.plugin.tomcat78x.TomcatExceptionInterceptor";

    @Override
    protected ClassMatch enhanceClass() {
@@ -52,13 +59,26 @@ public class TomcatInstrumentation extends ClassInstanceMethodsEnhancePluginDefi

                @Override
                public String getMethodsInterceptor() {
                    return INTERCEPT_CLASS;
                    return INVOKE_INTERCEPT_CLASS;
                }

                @Override
                public boolean isOverrideArgs() {
                    return false;
                }
            },
            new InstanceMethodsInterceptPoint() {
                @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
                    return named("exception");
                }

                @Override public String getMethodsInterceptor() {
                    return EXCEPTION_INTERCEPT_CLASS;
                }

                @Override public boolean isOverrideArgs() {
                    return false;
                }
            }
        };
    }
Loading