Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
b934a143
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 大约 1 年
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
b934a143
编写于
5月 06, 2021
作者:
L
liqiangz
提交者:
GitHub
5月 06, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `okhttp-4.x` plugin (#6899)
上级
17fffe8e
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
491 addition
and
30 deletion
+491
-30
CHANGES.md
CHANGES.md
+1
-0
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/pom.xml
+6
-0
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/AbstractOkhttpInstrumentation.java
...lugin/okhttp/v3/define/AbstractOkhttpInstrumentation.java
+29
-0
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/AsyncCallInstrumentation.java
...apm/plugin/okhttp/v3/define/AsyncCallInstrumentation.java
+3
-4
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/CallbackInstrumentation.java
.../apm/plugin/okhttp/v3/define/CallbackInstrumentation.java
+3
-4
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java
.../apm/plugin/okhttp/v3/define/RealCallInstrumentation.java
+3
-4
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptorTest.java
...walking/apm/plugin/okhttp/v3/RealCallInterceptorTest.java
+1
-0
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/pom.xml
+52
-0
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v4/define/AbstractOkhttpInstrumentation.java
...lugin/okhttp/v4/define/AbstractOkhttpInstrumentation.java
+29
-0
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v4/define/AsyncCallInstrumentation.java
...apm/plugin/okhttp/v4/define/AsyncCallInstrumentation.java
+76
-0
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v4/define/CallbackInstrumentation.java
.../apm/plugin/okhttp/v4/define/CallbackInstrumentation.java
+78
-0
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v4/define/RealCallInstrumentation.java
.../apm/plugin/okhttp/v4/define/RealCallInstrumentation.java
+103
-0
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/resources/skywalking-plugin.def
...khttp-4.x-plugin/src/main/resources/skywalking-plugin.def
+19
-0
apm-sniffer/apm-sdk-plugin/okhttp-common/pom.xml
apm-sniffer/apm-sdk-plugin/okhttp-common/pom.xml
+56
-0
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/AsyncCallInterceptor.java
...alking/apm/plugin/okhttp/common/AsyncCallInterceptor.java
+4
-3
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/EnhanceRequiredInfo.java
...walking/apm/plugin/okhttp/common/EnhanceRequiredInfo.java
+1
-1
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/EnqueueInterceptor.java
...ywalking/apm/plugin/okhttp/common/EnqueueInterceptor.java
+3
-2
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/OnFailureInterceptor.java
...alking/apm/plugin/okhttp/common/OnFailureInterceptor.java
+3
-2
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/OnResponseInterceptor.java
...lking/apm/plugin/okhttp/common/OnResponseInterceptor.java
+3
-2
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/RealCallInterceptor.java
...walking/apm/plugin/okhttp/common/RealCallInterceptor.java
+7
-6
apm-sniffer/apm-sdk-plugin/pom.xml
apm-sniffer/apm-sdk-plugin/pom.xml
+2
-0
docs/en/setup/service-agent/java-agent/Plugin-list.md
docs/en/setup/service-agent/java-agent/Plugin-list.md
+1
-0
docs/en/setup/service-agent/java-agent/Supported-list.md
docs/en/setup/service-agent/java-agent/Supported-list.md
+1
-1
test/plugin/scenarios/okhttp-scenario/support-version.list
test/plugin/scenarios/okhttp-scenario/support-version.list
+7
-1
未找到文件。
CHANGES.md
浏览文件 @
b934a143
...
...
@@ -22,6 +22,7 @@ Release Notes.
*
fix a bug that spring-mvc set an error endpoint name if the controller class annotation implements an interface.
*
Add an optional agent plugin to support mybatis.
*
Add
`spring-cloud-gateway-3.x`
optional plugin.
*
Add
`okhttp-4.x`
plugin.
#### OAP-Backend
*
BugFix: filter invalid Envoy access logs whose socket address is empty.
...
...
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/pom.xml
浏览文件 @
b934a143
...
...
@@ -40,5 +40,11 @@
<version>
${okhttp.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
apm-okhttp-common
</artifactId>
<version>
${project.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/AbstractOkhttpInstrumentation.java
0 → 100644
浏览文件 @
b934a143
/*
* 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.okhttp.v3.define
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
public
abstract
class
AbstractOkhttpInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
WITHNESS_CLASSES
=
"okhttp3.RealCall"
;
@Override
protected
final
String
[]
witnessClasses
()
{
return
new
String
[]
{
WITHNESS_CLASSES
};
}
}
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/AsyncCallInstrumentation.java
浏览文件 @
b934a143
...
...
@@ -22,14 +22,13 @@ import net.bytebuddy.description.method.MethodDescription;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
any
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
public
class
AsyncCallInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
class
AsyncCallInstrumentation
extends
AbstractOkhttpInstrumentation
{
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
...
...
@@ -42,7 +41,7 @@ public class AsyncCallInstrumentation extends ClassInstanceMethodsEnhancePluginD
@Override
public
String
getConstructorInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.
v3
.AsyncCallInterceptor"
;
return
"org.apache.skywalking.apm.plugin.okhttp.
common
.AsyncCallInterceptor"
;
}
}
};
...
...
@@ -59,7 +58,7 @@ public class AsyncCallInstrumentation extends ClassInstanceMethodsEnhancePluginD
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.
v3
.AsyncCallInterceptor"
;
return
"org.apache.skywalking.apm.plugin.okhttp.
common
.AsyncCallInterceptor"
;
}
@Override
...
...
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/CallbackInstrumentation.java
浏览文件 @
b934a143
...
...
@@ -22,13 +22,12 @@ import net.bytebuddy.description.method.MethodDescription;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
HierarchyMatch
.
byHierarchyMatch
;
public
class
CallbackInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
class
CallbackInstrumentation
extends
AbstractOkhttpInstrumentation
{
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
...
...
@@ -45,7 +44,7 @@ public class CallbackInstrumentation extends ClassInstanceMethodsEnhancePluginDe
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.
v3
.OnFailureInterceptor"
;
return
"org.apache.skywalking.apm.plugin.okhttp.
common
.OnFailureInterceptor"
;
}
@Override
...
...
@@ -61,7 +60,7 @@ public class CallbackInstrumentation extends ClassInstanceMethodsEnhancePluginDe
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.
v3
.OnResponseInterceptor"
;
return
"org.apache.skywalking.apm.plugin.okhttp.
common
.OnResponseInterceptor"
;
}
@Override
...
...
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/define/RealCallInstrumentation.java
浏览文件 @
b934a143
...
...
@@ -22,7 +22,6 @@ import net.bytebuddy.description.method.MethodDescription;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.NameMatch
;
...
...
@@ -30,7 +29,7 @@ import static net.bytebuddy.matcher.ElementMatchers.any;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
public
class
RealCallInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
class
RealCallInstrumentation
extends
AbstractOkhttpInstrumentation
{
/**
* Enhance class.
...
...
@@ -40,7 +39,7 @@ public class RealCallInstrumentation extends ClassInstanceMethodsEnhancePluginDe
/**
* Intercept class.
*/
private
static
final
String
INTERCEPT_CLASS
=
"org.apache.skywalking.apm.plugin.okhttp.
v3
.RealCallInterceptor"
;
private
static
final
String
INTERCEPT_CLASS
=
"org.apache.skywalking.apm.plugin.okhttp.
common
.RealCallInterceptor"
;
@Override
protected
ClassMatch
enhanceClass
()
{
...
...
@@ -91,7 +90,7 @@ public class RealCallInstrumentation extends ClassInstanceMethodsEnhancePluginDe
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.
v3
.EnqueueInterceptor"
;
return
"org.apache.skywalking.apm.plugin.okhttp.
common
.EnqueueInterceptor"
;
}
@Override
...
...
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptorTest.java
浏览文件 @
b934a143
...
...
@@ -25,6 +25,7 @@ import okhttp3.Response;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStorage
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint
;
import
org.apache.skywalking.apm.agent.test.tools.SpanAssert
;
import
org.apache.skywalking.apm.plugin.okhttp.common.RealCallInterceptor
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
...
...
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/pom.xml
0 → 100644
浏览文件 @
b934a143
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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>
8.6.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-okhttp-4.x-plugin
</artifactId>
<name>
okhttp-4.x-plugin
</name>
<packaging>
jar
</packaging>
<properties>
<okhttp.version>
4.9.0
</okhttp.version>
</properties>
<dependencies>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<version>
${okhttp.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
apm-okhttp-common
</artifactId>
<version>
${project.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v4/define/AbstractOkhttpInstrumentation.java
0 → 100644
浏览文件 @
b934a143
/*
* 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.okhttp.v4.define
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
public
abstract
class
AbstractOkhttpInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
WITHNESS_CLASSES
=
"okhttp3.internal.connection.RealCall"
;
@Override
protected
final
String
[]
witnessClasses
()
{
return
new
String
[]
{
WITHNESS_CLASSES
};
}
}
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v4/define/AsyncCallInstrumentation.java
0 → 100644
浏览文件 @
b934a143
/*
* 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.okhttp.v4.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
any
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
public
class
AsyncCallInstrumentation
extends
AbstractOkhttpInstrumentation
{
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[]
{
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
any
();
}
@Override
public
String
getConstructorInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.common.AsyncCallInterceptor"
;
}
}
};
}
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"run"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.common.AsyncCallInterceptor"
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
"okhttp3.internal.connection.RealCall$AsyncCall"
);
}
}
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v4/define/CallbackInstrumentation.java
0 → 100644
浏览文件 @
b934a143
/*
* 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.okhttp.v4.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
HierarchyMatch
.
byHierarchyMatch
;
public
class
CallbackInstrumentation
extends
AbstractOkhttpInstrumentation
{
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"onFailure"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.common.OnFailureInterceptor"
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"onResponse"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.common.OnResponseInterceptor"
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
byHierarchyMatch
(
new
String
[]
{
"okhttp3.Callback"
});
}
}
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v4/define/RealCallInstrumentation.java
0 → 100644
浏览文件 @
b934a143
/*
* 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.okhttp.v4.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.NameMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
any
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
takesArguments
;
public
class
RealCallInstrumentation
extends
AbstractOkhttpInstrumentation
{
/**
* Enhance class.
*/
private
static
final
String
ENHANCE_CLASS
=
"okhttp3.internal.connection.RealCall"
;
/**
* Intercept class.
*/
private
static
final
String
INTERCEPT_CLASS
=
"org.apache.skywalking.apm.plugin.okhttp.common.RealCallInterceptor"
;
@Override
protected
ClassMatch
enhanceClass
()
{
return
NameMatch
.
byName
(
ENHANCE_CLASS
);
}
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[]
{
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
any
();
}
@Override
public
String
getConstructorInterceptor
()
{
return
INTERCEPT_CLASS
;
}
}
};
}
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"execute"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"enqueue"
).
and
(
takesArguments
(
1
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.okhttp.common.EnqueueInterceptor"
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
}
apm-sniffer/apm-sdk-plugin/okhttp-4.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
b934a143
# 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.
okhttp-4.x=org.apache.skywalking.apm.plugin.okhttp.v4.define.RealCallInstrumentation
okhttp-4.x=org.apache.skywalking.apm.plugin.okhttp.v4.define.CallbackInstrumentation
okhttp-4.x=org.apache.skywalking.apm.plugin.okhttp.v4.define.AsyncCallInstrumentation
apm-sniffer/apm-sdk-plugin/okhttp-common/pom.xml
0 → 100644
浏览文件 @
b934a143
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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>
<artifactId>
apm-sdk-plugin
</artifactId>
<groupId>
org.apache.skywalking
</groupId>
<version>
8.6.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-okhttp-common
</artifactId>
<packaging>
jar
</packaging>
<name>
okhttp-common
</name>
<url>
http://maven.apache.org
</url>
<properties>
<okhttp.version>
3.7.0
</okhttp.version>
</properties>
<dependencies>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
<version>
${okhttp.version}
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>
maven-deploy-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
apm-sniffer/apm-sdk-plugin/okhttp-
3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3
/AsyncCallInterceptor.java
→
apm-sniffer/apm-sdk-plugin/okhttp-
common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common
/AsyncCallInterceptor.java
浏览文件 @
b934a143
...
...
@@ -16,10 +16,8 @@
*
*/
package
org.apache.skywalking.apm.plugin.okhttp.
v3
;
package
org.apache.skywalking.apm.plugin.okhttp.
common
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
okhttp3.Headers
;
import
okhttp3.HttpUrl
;
import
okhttp3.Request
;
...
...
@@ -35,6 +33,9 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceM
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
/**
* {@link AsyncCallInterceptor} get the `EnhanceRequiredInfo` instance from `SkyWalkingDynamicField` and then put it
* into `AsyncCall` instance when the `AsyncCall` constructor called.
...
...
apm-sniffer/apm-sdk-plugin/okhttp-
3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3
/EnhanceRequiredInfo.java
→
apm-sniffer/apm-sdk-plugin/okhttp-
common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common
/EnhanceRequiredInfo.java
浏览文件 @
b934a143
...
...
@@ -16,7 +16,7 @@
*
*/
package
org.apache.skywalking.apm.plugin.okhttp.
v3
;
package
org.apache.skywalking.apm.plugin.okhttp.
common
;
import
org.apache.skywalking.apm.agent.core.context.ContextSnapshot
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
...
...
apm-sniffer/apm-sdk-plugin/okhttp-
3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3
/EnqueueInterceptor.java
→
apm-sniffer/apm-sdk-plugin/okhttp-
common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common
/EnqueueInterceptor.java
浏览文件 @
b934a143
...
...
@@ -16,9 +16,8 @@
*
*/
package
org.apache.skywalking.apm.plugin.okhttp.
v3
;
package
org.apache.skywalking.apm.plugin.okhttp.
common
;
import
java.lang.reflect.Method
;
import
okhttp3.Request
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
...
...
@@ -26,6 +25,8 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceC
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
java.lang.reflect.Method
;
/**
* {@link EnqueueInterceptor} create a local span and the prefix of the span operation name is start with `Async` when
* the `enqueue` method called and also put the `ContextSnapshot` and `RealCall` instance into the
...
...
apm-sniffer/apm-sdk-plugin/okhttp-
3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3
/OnFailureInterceptor.java
→
apm-sniffer/apm-sdk-plugin/okhttp-
common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common
/OnFailureInterceptor.java
浏览文件 @
b934a143
...
...
@@ -16,14 +16,15 @@
*
*/
package
org.apache.skywalking.apm.plugin.okhttp.
v3
;
package
org.apache.skywalking.apm.plugin.okhttp.
common
;
import
java.lang.reflect.Method
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
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
java.lang.reflect.Method
;
public
class
OnFailureInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
...
...
apm-sniffer/apm-sdk-plugin/okhttp-
3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3
/OnResponseInterceptor.java
→
apm-sniffer/apm-sdk-plugin/okhttp-
common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common
/OnResponseInterceptor.java
浏览文件 @
b934a143
...
...
@@ -16,15 +16,16 @@
*
*/
package
org.apache.skywalking.apm.plugin.okhttp.
v3
;
package
org.apache.skywalking.apm.plugin.okhttp.
common
;
import
java.lang.reflect.Method
;
import
okhttp3.Response
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
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
java.lang.reflect.Method
;
/**
* {@link OnResponseInterceptor} validate the response code if it is great equal than 400. if so. the transaction status
* chang to `error`, or do nothing.
...
...
apm-sniffer/apm-sdk-plugin/okhttp-
3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3
/RealCallInterceptor.java
→
apm-sniffer/apm-sdk-plugin/okhttp-
common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common
/RealCallInterceptor.java
浏览文件 @
b934a143
...
...
@@ -16,10 +16,8 @@
*
*/
package
org.apache.skywalking.apm.plugin.okhttp.
v3
;
package
org.apache.skywalking.apm.plugin.okhttp.
common
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
okhttp3.Headers
;
import
okhttp3.HttpUrl
;
import
okhttp3.Request
;
...
...
@@ -36,6 +34,9 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceM
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
/**
* {@link RealCallInterceptor} intercept the synchronous http calls by the discovery of okhttp.
*/
...
...
@@ -47,9 +48,9 @@ public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, In
}
/**
* Get the {@link
okhttp3.
Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host,
* port, kind, component, url from {@link
okhttp3.
Request}. Through the reflection of the way, set the http header
* of context data into {@link
okhttp3.
Request#headers}.
* Get the {@link Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host,
* port, kind, component, url from {@link Request}. Through the reflection of the way, set the http header
* of context data into {@link Request#headers}.
*
* @param result change this result, if you want to truncate the method.
*/
...
...
apm-sniffer/apm-sdk-plugin/pom.xml
浏览文件 @
b934a143
...
...
@@ -39,6 +39,8 @@
<module>
mongodb-4.x-plugin
</module>
<module>
feign-default-http-9.x-plugin
</module>
<module>
okhttp-3.x-plugin
</module>
<module>
okhttp-4.x-plugin
</module>
<module>
okhttp-common
</module>
<module>
spring-plugins
</module>
<module>
struts2-2.x-plugin
</module>
<module>
nutz-plugins
</module>
...
...
docs/en/setup/service-agent/java-agent/Plugin-list.md
浏览文件 @
b934a143
...
...
@@ -54,6 +54,7 @@
-
nutz-http-1.x
-
nutz-mvc-annotation-1.x
-
okhttp-3.x
-
okhttp-4.x
-
play-2.x
-
postgresql-8.x
-
pulsar
...
...
docs/en/setup/service-agent/java-agent/Supported-list.md
浏览文件 @
b934a143
...
...
@@ -22,7 +22,7 @@ metrics based on the tracing data.
*
HTTP Client
*
[
Feign
](
https://github.com/OpenFeign/feign
)
9.x
*
[
Netflix Spring Cloud Feign
](
https://github.com/spring-cloud/spring-cloud-openfeign
)
1.1.x -> 2.x
*
[
Okhttp
](
https://github.com/square/okhttp
)
3.x
*
[
Okhttp
](
https://github.com/square/okhttp
)
3.x
-> 4.x
*
[
Apache httpcomponent HttpClient
](
http://hc.apache.org/
)
2.0 -> 3.1, 4.2, 4.3
*
[
Spring RestTemplete
](
https://github.com/spring-projects/spring-framework
)
4.x
*
[
Jetty Client
](
http://www.eclipse.org/jetty/
)
9
...
...
test/plugin/scenarios/okhttp-scenario/support-version.list
浏览文件 @
b934a143
...
...
@@ -28,4 +28,10 @@
3.11.0
3.12.6
3.13.1
3.14.4
\ No newline at end of file
3.14.4
4.5.0
4.6.0
4.7.0
4.8.0
4.9.0
4.9.1
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录