Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
d19b0fe7
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 搜索 >>
提交
d19b0fe7
编写于
12月 01, 2015
作者:
Z
zhangxin10
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增HttpClient插件
上级
52e268f5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
201 addition
and
0 deletion
+201
-0
skywalking-sdk-plugin/httpclient-plugin/pom.xml
skywalking-sdk-plugin/httpclient-plugin/pom.xml
+33
-0
skywalking-sdk-plugin/httpclient-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/SWTracingHttpClient.java
...oud/skywalking/plugin/httpclient/SWTracingHttpClient.java
+132
-0
skywalking-sdk-plugin/httpclient-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/trace/HttpClientTracing.java
...skywalking/plugin/httpclient/trace/HttpClientTracing.java
+35
-0
skywalking-sdk-plugin/pom.xml
skywalking-sdk-plugin/pom.xml
+1
-0
未找到文件。
skywalking-sdk-plugin/httpclient-plugin/pom.xml
0 → 100644
浏览文件 @
d19b0fe7
<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>
skywalking-sdk-plugin
</artifactId>
<groupId>
com.ai.cloud
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
httpClient-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
httpClient-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.2.1
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
</project>
skywalking-sdk-plugin/httpclient-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/SWTracingHttpClient.java
0 → 100644
浏览文件 @
d19b0fe7
package
com.ai.cloud.skywalking.plugin.httpclient
;
import
com.ai.cloud.skywalking.plugin.httpclient.trace.HttpClientTracing
;
import
org.apache.http.HttpHost
;
import
org.apache.http.HttpRequest
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.ResponseHandler
;
import
org.apache.http.client.methods.HttpUriRequest
;
import
org.apache.http.conn.ClientConnectionManager
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.params.HttpParams
;
import
org.apache.http.protocol.HttpContext
;
import
java.io.IOException
;
public
class
SWTracingHttpClient
implements
HttpClient
{
private
static
final
String
DEFAULT_TRACE_NAME
=
"SkyWalking-TRACING-NAME"
;
private
HttpClient
client
;
private
String
traceName
;
public
SWTracingHttpClient
(
HttpClient
client
,
String
traceName
)
{
this
.
client
=
client
;
this
.
traceName
=
traceName
;
}
public
SWTracingHttpClient
(
String
traceName
)
{
super
();
this
.
traceName
=
traceName
;
}
public
SWTracingHttpClient
()
{
client
=
new
DefaultHttpClient
();
this
.
traceName
=
DEFAULT_TRACE_NAME
;
}
@Override
public
HttpParams
getParams
()
{
return
client
.
getParams
();
}
@Override
public
ClientConnectionManager
getConnectionManager
()
{
return
client
.
getConnectionManager
();
}
@Override
public
HttpResponse
execute
(
final
HttpUriRequest
httpUriRequest
)
throws
IOException
,
ClientProtocolException
{
return
HttpClientTracing
.
execute
(
httpUriRequest
.
getURI
().
toString
(),
traceName
,
httpUriRequest
,
new
HttpClientTracing
.
Executor
<
HttpResponse
>()
{
@Override
public
HttpResponse
execute
()
throws
IOException
{
return
client
.
execute
(
httpUriRequest
);
}
});
}
@Override
public
HttpResponse
execute
(
final
HttpUriRequest
httpUriRequest
,
final
HttpContext
httpContext
)
throws
IOException
,
ClientProtocolException
{
return
HttpClientTracing
.
execute
(
httpUriRequest
.
getURI
().
toString
(),
traceName
,
httpUriRequest
,
new
HttpClientTracing
.
Executor
<
HttpResponse
>()
{
@Override
public
HttpResponse
execute
()
throws
IOException
{
return
client
.
execute
(
httpUriRequest
,
httpContext
);
}
});
}
@Override
public
HttpResponse
execute
(
final
HttpHost
httpHost
,
final
HttpRequest
httpRequest
)
throws
IOException
,
ClientProtocolException
{
return
HttpClientTracing
.
execute
(
httpHost
.
toURI
(),
traceName
,
httpRequest
,
new
HttpClientTracing
.
Executor
<
HttpResponse
>()
{
@Override
public
HttpResponse
execute
()
throws
IOException
{
return
client
.
execute
(
httpHost
,
httpRequest
);
}
});
}
@Override
public
HttpResponse
execute
(
final
HttpHost
httpHost
,
final
HttpRequest
httpRequest
,
final
HttpContext
httpContext
)
throws
IOException
,
ClientProtocolException
{
return
HttpClientTracing
.
execute
(
httpHost
.
toURI
(),
traceName
,
httpRequest
,
new
HttpClientTracing
.
Executor
<
HttpResponse
>()
{
@Override
public
HttpResponse
execute
()
throws
IOException
{
return
client
.
execute
(
httpHost
,
httpRequest
,
httpContext
);
}
});
}
@Override
public
<
T
>
T
execute
(
final
HttpUriRequest
httpUriRequest
,
final
ResponseHandler
<?
extends
T
>
responseHandler
)
throws
IOException
,
ClientProtocolException
{
return
HttpClientTracing
.
execute
(
httpUriRequest
.
getURI
().
toString
(),
traceName
,
httpUriRequest
,
new
HttpClientTracing
.
Executor
<
T
>()
{
@Override
public
T
execute
()
throws
IOException
{
return
client
.
execute
(
httpUriRequest
,
responseHandler
);
}
});
}
@Override
public
<
T
>
T
execute
(
final
HttpUriRequest
httpUriRequest
,
final
ResponseHandler
<?
extends
T
>
responseHandler
,
final
HttpContext
httpContext
)
throws
IOException
,
ClientProtocolException
{
return
HttpClientTracing
.
execute
(
httpUriRequest
.
getURI
().
toString
(),
traceName
,
httpUriRequest
,
new
HttpClientTracing
.
Executor
<
T
>()
{
@Override
public
T
execute
()
throws
IOException
{
return
client
.
execute
(
httpUriRequest
,
responseHandler
,
httpContext
);
}
});
}
@Override
public
<
T
>
T
execute
(
final
HttpHost
httpHost
,
final
HttpRequest
httpRequest
,
final
ResponseHandler
<?
extends
T
>
responseHandler
)
throws
IOException
,
ClientProtocolException
{
return
HttpClientTracing
.
execute
(
httpHost
.
toURI
(),
traceName
,
httpRequest
,
new
HttpClientTracing
.
Executor
<
T
>()
{
@Override
public
T
execute
()
throws
IOException
{
return
client
.
execute
(
httpHost
,
httpRequest
,
responseHandler
);
}
});
}
@Override
public
<
T
>
T
execute
(
final
HttpHost
httpHost
,
final
HttpRequest
httpRequest
,
final
ResponseHandler
<?
extends
T
>
responseHandler
,
HttpContext
httpContext
)
throws
IOException
,
ClientProtocolException
{
return
HttpClientTracing
.
execute
(
httpHost
.
toURI
(),
traceName
,
httpRequest
,
new
HttpClientTracing
.
Executor
<
T
>()
{
@Override
public
T
execute
()
throws
IOException
{
return
client
.
execute
(
httpHost
,
httpRequest
,
responseHandler
);
}
});
}
}
skywalking-sdk-plugin/httpclient-plugin/src/main/java/com/ai/cloud/skywalking/plugin/httpclient/trace/HttpClientTracing.java
0 → 100644
浏览文件 @
d19b0fe7
package
com.ai.cloud.skywalking.plugin.httpclient.trace
;
import
com.ai.cloud.skywalking.buriedpoint.RPCBuriedPointSender
;
import
com.ai.cloud.skywalking.model.Identification
;
import
org.apache.http.HttpRequest
;
import
java.io.IOException
;
public
class
HttpClientTracing
{
private
static
RPCBuriedPointSender
sender
=
new
RPCBuriedPointSender
();
public
static
<
R
>
R
execute
(
String
url
,
String
traceHearName
,
HttpRequest
httpRequest
,
Executor
<
R
>
executor
)
throws
IOException
{
try
{
httpRequest
.
setHeader
(
traceHearName
,
sender
.
beforeSend
(
Identification
.
newBuilder
()
.
viewPoint
(
url
)
.
spanType
(
'W'
)
.
build
())
.
toString
());
return
executor
.
execute
();
}
catch
(
IOException
e
)
{
sender
.
handleException
(
e
);
throw
e
;
}
finally
{
sender
.
afterSend
();
}
}
public
interface
Executor
<
R
>
{
R
execute
()
throws
IOException
;
}
}
skywalking-sdk-plugin/pom.xml
浏览文件 @
d19b0fe7
...
...
@@ -10,6 +10,7 @@
<module>
spring-plugin
</module>
<module>
jdbc-plugin
</module>
<module>
web-plugin
</module>
<module>
httpclient-plugin
</module>
</modules>
<packaging>
pom
</packaging>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录