-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tag 2021.01.30 test otel enhance to sofa rpc for myself. committer:陈晨。
- Loading branch information
Showing
9 changed files
with
208 additions
and
19 deletions.
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
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
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,11 @@ | ||
### Open-Telemetry-Simple-SofaRpc 案例工程 | ||
|
||
> Open-Telemetry-Simple-SofaRpc 实际测试了个人为在Otel中为Sofa-Rpc所作的增强(个人测试使用)。 | ||
##### 测试模块快速开始 | ||
|
||
1. 确保[Guides 案例工程下的步骤](../README.md)执行完毕。 | ||
|
||
2. 启动此模块[otel-simple-sofarpc](https://github.com/chenmudu/open-telemetry-java-guides/tree/master/otel-simple-sofarpc/src/main/java/org/chenmudu/otel/sofarpc/quickly)下的QuickStartServer 和 QuickStartClient. | ||
|
||
3. 测试个人为sofa-rpc 在Otel中增强其RPC的功能。 |
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,26 @@ | ||
<?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"> | ||
<parent> | ||
<artifactId>open-telemetry-java-guides</artifactId> | ||
<groupId>org.chenmudu.otel</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>otel-simple-sofarpc</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.alipay.sofa</groupId> | ||
<artifactId>sofa-rpc-all</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
24 changes: 24 additions & 0 deletions
24
otel-simple-sofarpc/src/main/java/org/chenmudu/otel/sofarpc/quickly/HelloService.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,24 @@ | ||
/* | ||
* 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.chenmudu.otel.sofarpc.quickly; | ||
|
||
/** | ||
* Quick Start demo interface | ||
*/ | ||
public interface HelloService { | ||
String sayHello(String string); | ||
} |
31 changes: 31 additions & 0 deletions
31
otel-simple-sofarpc/src/main/java/org/chenmudu/otel/sofarpc/quickly/HelloServiceImpl.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,31 @@ | ||
/* | ||
* 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.chenmudu.otel.sofarpc.quickly; | ||
|
||
/** | ||
* Quick Start demo implements | ||
*/ | ||
public class HelloServiceImpl implements HelloService { | ||
|
||
//private final static Logger LOGGER = LoggerFactory.getLogger(HelloServiceImpl.class); | ||
|
||
@Override | ||
public String sayHello(String string) { | ||
System.out.println("Server receive: " + string); | ||
return "hello " + string + " !"; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
otel-simple-sofarpc/src/main/java/org/chenmudu/otel/sofarpc/quickly/QuickStartClient.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.chenmudu.otel.sofarpc.quickly; | ||
|
||
import com.alipay.sofa.rpc.config.ConsumerConfig; | ||
|
||
/** | ||
* Quick Start client | ||
*/ | ||
public class QuickStartClient { | ||
|
||
// private final static Logger LOGGER = LoggerFactory.getLogger(QuickStartClient.class); | ||
|
||
public static void main(String[] args) { | ||
|
||
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>() | ||
.setInterfaceId(HelloService.class.getName()) // 指定接口 | ||
.setProtocol("bolt") // 指定协议 | ||
.setDirectUrl("bolt://127.0.0.1:12200") // 指定直连地址 | ||
.setConnectTimeout(10 * 1000); | ||
|
||
HelloService helloService = consumerConfig.refer(); | ||
|
||
while (true) { | ||
try { | ||
System.out.println(helloService.sayHello("world")); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
try { | ||
Thread.sleep(2000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
otel-simple-sofarpc/src/main/java/org/chenmudu/otel/sofarpc/quickly/QuickStartServer.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,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.chenmudu.otel.sofarpc.quickly; | ||
|
||
import com.alipay.sofa.rpc.config.ProviderConfig; | ||
import com.alipay.sofa.rpc.config.ServerConfig; | ||
|
||
/** | ||
* Quick Start Server | ||
*/ | ||
public class QuickStartServer { | ||
|
||
public static void main(String[] args) { | ||
ServerConfig serverConfig = new ServerConfig().setProtocol("bolt") // 设置一个协议,默认bolt | ||
.setPort(12200) // 设置一个端口,默认12200 | ||
.setDaemon(false); // 非守护线程 | ||
|
||
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>() | ||
.setInterfaceId(HelloService.class.getName()) // 指定接口 | ||
.setRef(new HelloServiceImpl()) // 指定实现 | ||
.setServer(serverConfig); // 指定服务端 | ||
|
||
providerConfig.export(); // 发布服务 | ||
} | ||
} |
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