Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
279ae78
Fix ci
wayilau Jun 21, 2019
155f851
Add Hessian Config
wayilau Jun 21, 2019
8d354f6
Fix config.
wayilau Jun 21, 2019
0d3c35e
rename plugin.
wayilau Jun 21, 2019
fdf28d5
Add hessian tags.
wayilau Jun 21, 2019
baf4c46
remote unused import
wayilau Jun 21, 2019
ea19c45
Remove the third classes.
wayilau Jun 24, 2019
42d293d
Merge branch 'master' into feature2
wayilau Jun 24, 2019
f310370
Fix ci.
wayilau Jun 24, 2019
685f160
Fix testcases.
wayilau Jun 24, 2019
bcde191
Merge branch 'master' into feature2
wayilau Jun 26, 2019
306b4e5
Merge branch 'master' into feature2
wu-sheng Jun 27, 2019
794598d
Merge branch 'master' into feature2
wayilau Jul 2, 2019
0656f63
Fix version 6.3.0.
wayilau Jul 2, 2019
89bfcb5
Add config for hessian server side.
wayilau Jul 2, 2019
85e480a
Remove unused code.
wayilau Jul 3, 2019
543c4e9
Fix the config.
wayilau Jul 3, 2019
24273e7
Remove unused import.
wayilau Jul 3, 2019
19dbbc0
Merge branch 'master' into feature2
wayilau Jul 3, 2019
e788a2a
Merge branch 'master' into feature2
wu-sheng Jul 3, 2019
58d70c0
Fix the docs. & Fix hessian config as variable to Config.
wayilau Jul 3, 2019
b099bbe
Merge branch 'feature2' of github.com:wayilau/skywalking into feature2
wayilau Jul 3, 2019
21991e6
Fix md.
wayilau Jul 3, 2019
e81507d
Rename name of the hessian config.
wayilau Jul 3, 2019
22cc4a4
Merge branch 'master' into feature2
kezhenxu94 Jul 8, 2019
fc1e4c6
Merge branch 'master' into feature2
wayilau Jul 8, 2019
86de488
Remove the properties in the pom.xml, change the hessian jar scope.
wayilau Jul 11, 2019
1ffe4a2
Merge branch 'feature2' of github.com:wayilau/skywalking into feature2
wayilau Jul 11, 2019
a8a4a0e
Merge branch 'master' into feature2
wayilau Jul 11, 2019
3620e1c
Merge branch 'master' into feature2
wu-sheng Jul 13, 2019
171f892
Merge branch 'master' into feature2
wu-sheng Jul 18, 2019
9a049dc
Merge branch 'master' into feature2
wayilau Jul 19, 2019
306a4b5
Merge branch 'master' into feature2
wu-sheng Jul 21, 2019
9a6334f
Remove hessian_uri & Mv the matcher to instrumentation define.
wayilau Jul 22, 2019
3cd7c7b
fix the import.
wayilau Jul 22, 2019
ac49d1b
Give the full name.
wayilau Jul 22, 2019
3a7231a
Fix the typos & Fix the conditions when stop span. & Fix follow usefu…
wayilau Jul 22, 2019
53bffe0
Fix the index.
wayilau Jul 22, 2019
a30640b
Remove third party instrumentation.
wayilau Jul 30, 2019
42eca6b
Fix the style.
wayilau Jul 30, 2019
cceeccb
Remove lombok & fix ci.
wayilau Jul 30, 2019
de6ca7e
Fix server side interceptor.
wayilau Jul 30, 2019
8a79bd9
Merge branch 'master' into feature2
wayilau Jul 31, 2019
e644426
Fix ci.
wayilau Jul 31, 2019
6d04736
Merge branch 'feature2' of github.com:wayilau/skywalking into feature2
wayilau Jul 31, 2019
c75bb21
Move protecd to public to fix the ci.
wayilau Jul 31, 2019
758110d
Merge branch 'master' into feature2
kezhenxu94 Jul 31, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public class ComponentsDefine {
public static final OfficialComponent SOLRJ = new OfficialComponent(63, "solrj");

public static final OfficialComponent SPRING_ASYNC = new OfficialComponent(65, "SpringAsync");

public static final OfficialComponent HESSIAN = new OfficialComponent(66, "Hessian");


private static ComponentsDefine INSTANCE = new ComponentsDefine();

Expand Down Expand Up @@ -184,6 +187,7 @@ public ComponentsDefine() {
addComponent(SPRING_CLOUD_GATEWAY);
addComponent(RESTEASY);
addComponent(SOLRJ);
addComponent(HESSIAN);
}

private void addComponent(OfficialComponent component) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,12 @@ public static class SolrJ {
public static boolean TRACE_OPS_PARAMS = false;
}

public static class Hessian {
/**
* If true, the request uri name will be used as the operation name instead of the interface class name, default is false.
*/
public static boolean USE_URL_AS_OPERATION_NAME = false;
}

}
}
54 changes: 54 additions & 0 deletions apm-sniffer/apm-sdk-plugin/hessian-4.0.x-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-sdk-plugin</artifactId>
<version>6.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>apm-hessian-4.0.x-plugin</artifactId>

<name>hessian-4.0.x-plugin</name>

<properties>
<hessian.version>4.0.38</hessian.version>
</properties>

<dependencies>
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>${hessian.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
Comment thread
wu-sheng marked this conversation as resolved.
<scope>provided</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.skywalking.apm.plugin.hessian.v4;

/**
* Constant field for hessian plugin
*
* @author Alan Lau
*/
public class Constants {

public static final String ENHANCE_CLASS = "com.caucho.hessian.client.HessianProxy";

public static final String HESSIAN_SERVICE_EXPORTER_CLASS = "org.springframework.remoting.caucho.HessianServiceExporter";

public static final String ADDHEADER_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.hessian.v4.HessianAddHeaderInterceptor";

public static final String HESSIAN_SENDREQUEST_CLASS = "org.apache.skywalking.apm.plugin.hessian.v4.HessianProxySendRequestInterceptor";

public static final String HESSIAN_SERVLET_ENHANCE_CLASS = "com.caucho.hessian.server.HessianSkeleton";

public static final String SKELETON_INTERCPTOR_CLASS = "org.apache.skywalking.apm.plugin.hessian.v4.HessianSkeletonInterceptor";

public static final String CONSTRUCT_INTERCEPTOR = "org.apache.skywalking.apm.plugin.hessian.v4.HessianProxyConstructorInterceptor";

public static final String SKELETON_CONSTRUCT_INTERCEPTOR = "org.apache.skywalking.apm.plugin.hessian.v4.HessianSkeletonConstructorInterceptor";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.skywalking.apm.plugin.hessian.v4;

import com.caucho.hessian.client.HessianURLConnection;
import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;

/**
* intercept method {@link HessianURLConnection#addHeader}.
*
* @author Alan Lau
*/
public class HessianAddHeaderInterceptor implements InstanceMethodsAroundInterceptor {

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {

HessianURLConnection conn = (HessianURLConnection)allArguments[0];
ContextCarrier carrier = new ContextCarrier();
ContextManager.inject(carrier);

CarrierItem next = carrier.items();
while (next.hasNext()) {
next = next.next();
conn.addHeader(next.getHeadKey(), next.getHeadValue());
}

}

@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) {
dealException(t);
}

public void dealException(Throwable t) {
AbstractSpan activeSpan = ContextManager.activeSpan();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

activeSpan.errorOccurred();
activeSpan.log(t);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.skywalking.apm.plugin.hessian.v4;

import java.net.URL;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
import org.apache.skywalking.apm.plugin.hessian.v4.define.HessianEnhanceCache;

/**
* intercept HessianProxy
*
* @author Alan Lau
*/
public class HessianProxyConstructorInterceptor implements InstanceConstructorInterceptor {

@Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {

if (allArguments.length < 3) {
return;
}

if (allArguments[0] == null) {
return;
}

URL url = (URL)allArguments[0];
Class clazz = (Class)allArguments[2];
HessianEnhanceCache cache = new HessianEnhanceCache();
cache.setUrl(url);
cache.setObj(clazz);
objInst.setSkyWalkingDynamicField(cache);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.skywalking.apm.plugin.hessian.v4;

import java.lang.reflect.Method;
import java.net.URL;
import org.apache.skywalking.apm.agent.core.conf.Config;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.apache.skywalking.apm.plugin.hessian.v4.define.HessianEnhanceCache;

/**
* intercept sendRequest of HessianProxy
*
* @author Alan Lau
*/
public class HessianProxySendRequestInterceptor implements InstanceMethodsAroundInterceptor {

@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {

if (allArguments.length < 0) {
return;
}

if (allArguments.length < 0) {
return;
}
HessianEnhanceCache cache = (HessianEnhanceCache)objInst.getSkyWalkingDynamicField();
URL url = cache.getUrl();
AbstractSpan span;
final ContextCarrier contextCarrier = new ContextCarrier();
String operateName;

if (Config.Plugin.Hessian.USE_URL_AS_OPERATION_NAME) {
operateName = url.getPath();
span = ContextManager.createExitSpan(operateName, contextCarrier, String.format(":", url.getHost(), url.getPort()));
Tags.URL.set(span, url.getPath());
} else {
Object clazz = cache.getObj();
if (clazz == null) {
return;
}
operateName = ((Class)clazz).getName();
span = ContextManager.createExitSpan(operateName, contextCarrier, String.format(":", url.getHost(), url.getPort()));
Tags.URL.set(span, operateName);
}

span.setOperationName(operateName);
span.setComponent(ComponentsDefine.HESSIAN);
span.start(System.currentTimeMillis());
SpanLayer.asRPCFramework(span);
}

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

if (allArguments.length < 0) {
return ret;
}

ContextManager.stopSpan();
return ret;
}

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

public void dealException(Throwable t) {
AbstractSpan activeSpan = ContextManager.activeSpan();
activeSpan.errorOccurred();
activeSpan.log(t);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.skywalking.apm.plugin.hessian.v4;

import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;

/**
* @author Alan Lau
*/
public class HessianSkeletonConstructorInterceptor implements InstanceConstructorInterceptor {

@Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {

if (allArguments[0] == null) {
return;
}

Object service = allArguments[1];
objInst.setSkyWalkingDynamicField(service);

}
}
Loading