-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/lytscu/skywalking into d…
…evelop y
- Loading branch information
Showing
22 changed files
with
1,567 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
71 changes: 71 additions & 0 deletions
71
apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/pom.xml
This file contains 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,71 @@ | ||
<?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 | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.apache.skywalking</groupId> | ||
<artifactId>apm-sdk-plugin</artifactId> | ||
<version>5.0.0-alpha</version> | ||
</parent> | ||
|
||
<artifactId>apm-httpasyncclient-4.x-plugin</artifactId> | ||
|
||
<name>httpasyncclient-4.x-plugin</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpasyncclient</artifactId> | ||
<version>4.1.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpasyncclient-cache</artifactId> | ||
<version>4.1.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<!-- 源码插件 --> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<!-- 发布时自动将源码同时发布的配置 --> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
53 changes: 53 additions & 0 deletions
53
.../src/main/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/ConnectIterceptor.java
This file contains 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,53 @@ | ||
/* | ||
* 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.httpasyncclient.v4; | ||
|
||
import java.lang.reflect.Method; | ||
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; | ||
|
||
/** | ||
* Pass ref accross thread by SessionRequest. | ||
* | ||
* @author liyuntao | ||
*/ | ||
|
||
public class ConnectIterceptor implements InstanceMethodsAroundInterceptor { | ||
|
||
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { | ||
|
||
} | ||
|
||
@Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, Object ret) throws Throwable { | ||
((EnhancedInstance)ret).setSkyWalkingDynamicField(ContextManager.capture()); | ||
return ret; | ||
} | ||
|
||
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, Throwable t) { | ||
AbstractSpan activeSpan = ContextManager.activeSpan(); | ||
activeSpan.errorOccurred(); | ||
activeSpan.log(t); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...apache/skywalking/apm/plugin/httpasyncclient/v4/DefaultConnectingIOReactorIterceptor.java
This file contains 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,58 @@ | ||
/* | ||
* 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.httpasyncclient.v4; | ||
|
||
import java.lang.reflect.Method; | ||
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.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; | ||
|
||
/** | ||
* Create local span :httpasyncclient/SocketChannel, to showcase the ability to connect to the remote host. | ||
* | ||
* @author liyuntao | ||
*/ | ||
|
||
public class DefaultConnectingIOReactorIterceptor implements InstanceMethodsAroundInterceptor { | ||
|
||
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { | ||
|
||
AbstractSpan span = ContextManager.createLocalSpan("httpasyncclient/DefaultConnectingIOReactor:"); | ||
span.setComponent(ComponentsDefine.HTTP_ASYNC_CLIENT).setLayer(SpanLayer.HTTP); | ||
|
||
} | ||
|
||
@Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, Object ret) throws Throwable { | ||
ContextManager.stopSpan(); | ||
return ret; | ||
} | ||
|
||
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, Throwable t) { | ||
AbstractSpan activeSpan = ContextManager.activeSpan(); | ||
activeSpan.errorOccurred(); | ||
activeSpan.log(t); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
.../src/main/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/FailedInterceptor.java
This file contains 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,63 @@ | ||
/* | ||
* 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.httpasyncclient.v4; | ||
|
||
import java.lang.reflect.Method; | ||
import org.apache.http.nio.reactor.SessionRequest; | ||
import org.apache.skywalking.apm.agent.core.context.ContextManager; | ||
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; | ||
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; | ||
|
||
/** | ||
* Create a local sapn and passing ref accross thread by SessionRequest. | ||
* | ||
* @author liyuntao | ||
*/ | ||
|
||
public class FailedInterceptor implements InstanceMethodsAroundInterceptor { | ||
|
||
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { | ||
|
||
SessionRequest request = (SessionRequest)allArguments[0]; | ||
|
||
AbstractSpan localSpan = ContextManager.createLocalSpan("httpasyncclient/request"); | ||
localSpan.setComponent(ComponentsDefine.HTTP_ASYNC_CLIENT).setLayer(SpanLayer.HTTP); | ||
Object cacheValue = ((EnhancedInstance)request).getSkyWalkingDynamicField(); | ||
ContextManager.continued((ContextSnapshot)cacheValue); | ||
|
||
} | ||
|
||
@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) { | ||
AbstractSpan activeSpan = ContextManager.activeSpan(); | ||
activeSpan.errorOccurred(); | ||
activeSpan.log(t); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncResponseConsumerInterceptor.java
This file contains 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,64 @@ | ||
/* | ||
* 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.httpasyncclient.v4; | ||
|
||
import java.lang.reflect.Method; | ||
import org.apache.http.nio.protocol.HttpAsyncRequestProducer; | ||
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; | ||
|
||
/** | ||
* End a local span for {@link org.apache.http.impl.nio.client.CloseableHttpAsyncClient#execute} called by | ||
* application. | ||
* | ||
* @author liyuntao | ||
*/ | ||
|
||
public class HttpAsyncResponseConsumerInterceptor implements InstanceMethodsAroundInterceptor { | ||
|
||
@Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { | ||
|
||
HttpAsyncRequestProducer producer = (HttpAsyncRequestProducer)allArguments[0]; | ||
String uri = producer.generateRequest().getRequestLine().getUri(); | ||
AbstractSpan span = ContextManager.createLocalSpan("HttpAsyncClient/execute"); | ||
span.setComponent(ComponentsDefine.HTTP_ASYNC_CLIENT).setLayer(SpanLayer.HTTP); | ||
Tags.URL.set(span, uri); | ||
|
||
} | ||
|
||
@Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, Object ret) throws Throwable { | ||
ContextManager.stopSpan(); | ||
return ret; | ||
} | ||
|
||
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, | ||
Class<?>[] argumentsTypes, Throwable t) { | ||
AbstractSpan activeSpan = ContextManager.activeSpan(); | ||
activeSpan.errorOccurred(); | ||
activeSpan.log(t); | ||
} | ||
} |
Oops, something went wrong.