-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Support Hessian 4.0.x. #2644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Support Hessian 4.0.x. #2644
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
279ae78
Fix ci
wayilau 155f851
Add Hessian Config
wayilau 8d354f6
Fix config.
wayilau 0d3c35e
rename plugin.
wayilau fdf28d5
Add hessian tags.
wayilau baf4c46
remote unused import
wayilau ea19c45
Remove the third classes.
wayilau 42d293d
Merge branch 'master' into feature2
wayilau f310370
Fix ci.
wayilau 685f160
Fix testcases.
wayilau bcde191
Merge branch 'master' into feature2
wayilau 306b4e5
Merge branch 'master' into feature2
wu-sheng 794598d
Merge branch 'master' into feature2
wayilau 0656f63
Fix version 6.3.0.
wayilau 89bfcb5
Add config for hessian server side.
wayilau 85e480a
Remove unused code.
wayilau 543c4e9
Fix the config.
wayilau 24273e7
Remove unused import.
wayilau 19dbbc0
Merge branch 'master' into feature2
wayilau e788a2a
Merge branch 'master' into feature2
wu-sheng 58d70c0
Fix the docs. & Fix hessian config as variable to Config.
wayilau b099bbe
Merge branch 'feature2' of github.com:wayilau/skywalking into feature2
wayilau 21991e6
Fix md.
wayilau e81507d
Rename name of the hessian config.
wayilau 22cc4a4
Merge branch 'master' into feature2
kezhenxu94 fc1e4c6
Merge branch 'master' into feature2
wayilau 86de488
Remove the properties in the pom.xml, change the hessian jar scope.
wayilau 1ffe4a2
Merge branch 'feature2' of github.com:wayilau/skywalking into feature2
wayilau a8a4a0e
Merge branch 'master' into feature2
wayilau 3620e1c
Merge branch 'master' into feature2
wu-sheng 171f892
Merge branch 'master' into feature2
wu-sheng 9a049dc
Merge branch 'master' into feature2
wayilau 306a4b5
Merge branch 'master' into feature2
wu-sheng 9a6334f
Remove hessian_uri & Mv the matcher to instrumentation define.
wayilau 3cd7c7b
fix the import.
wayilau ac49d1b
Give the full name.
wayilau 3a7231a
Fix the typos & Fix the conditions when stop span. & Fix follow usefu…
wayilau 53bffe0
Fix the index.
wayilau a30640b
Remove third party instrumentation.
wayilau 42eca6b
Fix the style.
wayilau cceeccb
Remove lombok & fix ci.
wayilau de6ca7e
Fix server side interceptor.
wayilau 8a79bd9
Merge branch 'master' into feature2
wayilau e644426
Fix ci.
wayilau 6d04736
Merge branch 'feature2' of github.com:wayilau/skywalking into feature2
wayilau c75bb21
Move protecd to public to fix the ci.
wayilau 758110d
Merge branch 'master' into feature2
kezhenxu94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| </dependencies> | ||
|
|
||
| </project> | ||
44 changes: 44 additions & 0 deletions
44
...ian-4.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hessian/v4/Constants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; | ||
|
|
||
| } |
70 changes: 70 additions & 0 deletions
70
...rc/main/java/org/apache/skywalking/apm/plugin/hessian/v4/HessianAddHeaderInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| activeSpan.errorOccurred(); | ||
| activeSpan.log(t); | ||
| } | ||
| } | ||
51 changes: 51 additions & 0 deletions
51
.../java/org/apache/skywalking/apm/plugin/hessian/v4/HessianProxyConstructorInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
|
|
||
| } | ||
| } |
104 changes: 104 additions & 0 deletions
104
.../java/org/apache/skywalking/apm/plugin/hessian/v4/HessianProxySendRequestInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
39 changes: 39 additions & 0 deletions
39
...va/org/apache/skywalking/apm/plugin/hessian/v4/HessianSkeletonConstructorInterceptor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.