Skip to content
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

Integrate with sofa-tracer for support opentracing. #131

Merged
merged 11 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 20 additions & 3 deletions all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<organization>
<name>The Ant Financial</name>
<url>http://www.antfin.com/</url>
Expand All @@ -43,7 +43,7 @@
<developerConnection>scm:git:ssh://github.com/alipay/sofa-rpc.git</developerConnection>
<url>http://github.com/alipay/sofa-rpc/tree/master</url>
</scm>

<properties>
<!-- Build args -->
<maven.compiler.source>1.6</maven.compiler.source>
Expand All @@ -57,6 +57,7 @@
<hessian.version>3.3.0</hessian.version>
<resteasy.version>3.0.12.Final</resteasy.version>
<bolt.version>1.4.1</bolt.version>
<tracer.version>2.1.0</tracer.version>
<lookout.version>1.4.0</lookout.version>
</properties>

Expand Down Expand Up @@ -173,12 +174,21 @@
<artifactId>sofa-rpc-remoting-resteasy</artifactId>
<version>${sofa.rpc.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-tracer-opentracing</artifactId>
<version>${sofa.rpc.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-tracer-opentracing-resteasy</artifactId>
<version>${sofa.rpc.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-metrics-lookout</artifactId>
<version>${sofa.rpc.version}</version>
</dependency>

<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>bolt</artifactId>
Expand Down Expand Up @@ -209,6 +219,11 @@
<artifactId>hessian</artifactId>
<version>${hessian.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>tracer-core</artifactId>
<version>${tracer.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-netty4</artifactId>
Expand Down Expand Up @@ -319,6 +334,8 @@
<include>com.alipay.sofa:sofa-rpc-registry-zk</include>
<include>com.alipay.sofa:sofa-rpc-remoting-bolt</include>
<include>com.alipay.sofa:sofa-rpc-remoting-resteasy</include>
<include>com.alipay.sofa:sofa-rpc-tracer-opentracing</include>
<include>com.alipay.sofa:sofa-rpc-tracer-opentracing-resteasy</include>
<include>com.alipay.sofa:sofa-rpc-metrics-lookout</include>
<!-- TODO -->
</includes>
Expand Down
13 changes: 8 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<bolt.version>1.4.1</bolt.version>
<sofa.common.tools.version>1.0.12</sofa.common.tools.version>
<lookout.version>1.1.0</lookout.version>
<tracer.version>2.0.1</tracer.version>
<tracer.version>2.1.0</tracer.version>
<lookout.version>1.4.0</lookout.version>
<!-- Build args -->
<module.install.skip>true</module.install.skip>
Expand All @@ -63,7 +63,7 @@
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -251,7 +251,7 @@
<artifactId>hessian</artifactId>
<version>${hessian.version}</version>
</dependency>

<!-- zk client -->
<dependency>
<groupId>org.apache.curator</groupId>
Expand Down Expand Up @@ -322,14 +322,17 @@
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>

<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>tracer-core</artifactId>
<version>${tracer.version}</version>
</dependency>
<!-- lookout -->
<dependency>
<groupId>com.alipay.sofa.lookout</groupId>
<artifactId>lookout-api</artifactId>
<version>${lookout.version}</version>
</dependency>

<!-- Test libs -->
<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
// 是否允许请求和响应透传数据,关闭后,会提高性能
"invoke.baggage.enable": true,
/*-------------系统运行时相关配置开始-------------*/


/*-------------默认配置值开始-------------*/
// 默认代理类型
"default.proxy" : "javassist",
"default.proxy": "javassist",
// 默认网络层
"default.transport": "bolt",
// 默认tracer实现
"default.tracer": "",
"default.tracer": "sofaTracer",
/*-------------默认配置值结束-------------*/


Expand All @@ -41,6 +41,6 @@
"consumer.disconnect.timeout": 5000,
// 默认consumer调用provider超时时间
"consumer.invoke.timeout": 3000

/*-------------Consumer相关配置结束-------------*/
}
4 changes: 3 additions & 1 deletion extension-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<artifactId>sofa-rpc-extension-impl</artifactId>
<packaging>pom</packaging>

<modules>
<module>api-compatible</module>
<module>extension-common</module>
Expand All @@ -27,6 +27,8 @@
<module>remoting-resteasy</module>
<module>registry-local</module>
<module>registry-zk</module>
<module>tracer-opentracing</module>
<module>tracer-opentracing-resteasy</module>
<module>metrics-lookout</module>
</modules>

Expand Down
119 changes: 119 additions & 0 deletions extension-impl/tracer-opentracing-resteasy/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-extension-impl</artifactId>
<version>5.4.0</version>
</parent>

<artifactId>sofa-rpc-tracer-opentracing-resteasy</artifactId>

<dependencies>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-extension-common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-remoting-resteasy</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-tracer-opentracing</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-netty4</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<testSourceDirectory>src/test/java</testSourceDirectory>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/**</include>
</includes>
</testResource>
</testResources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>${module.install.skip}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>${module.deploy.skip}</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipTests}</skipTests>
<includes>
<!-- 这里需要根据自己的需要指定要跑的单元测试 -->
<include>**/*Test.java</include>
</includes>
<!-- 如无特殊需求,将forkMode设置为once -->
<forkMode>once</forkMode>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 com.alipay.sofa.rpc.event;

import com.alipay.sofa.rpc.tracer.sofatracer.RestTracerAdapter;
import com.alipay.sofa.rpc.tracer.Tracers;

/**
* @author <a href="mailto:zhanggeng.zg@antfin.com">zhanggeng</a>
*/
public class RestTracerSubscriber extends Subscriber {

@Override
public void onEvent(Event originEvent) {
if (!Tracers.isEnable()) {
return;
}
Class eventClass = originEvent.getClass();

if (eventClass == RestServerReceiveEvent.class) {
RestServerReceiveEvent event = (RestServerReceiveEvent) originEvent;
RestTracerAdapter.serverReceived(event.getRequest());
} else if (eventClass == RestServerSendEvent.class) {
RestServerSendEvent event = (RestServerSendEvent) originEvent;
RestTracerAdapter.serverSend(event.getResponse(), event.getThrowable());
}
}

}
Loading