-
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.03 add rabbit & kafka simple case to current otel guides.…
… committer:陈晨。 add kafka & rabbit simple case and update read me file contents.
- Loading branch information
Showing
21 changed files
with
589 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Open-Telemetry-Simple-Kafka 案例工程 | ||
|
||
> Open-Telemetry-Simple-Kafka 实际测试了 Spring Kafka 以及 Kafka Client。 | ||
##### 测试模块快速开始 | ||
|
||
1. 确保[Guides 案例工程下的步骤](../README.md)执行完毕。 | ||
|
||
2. 启动此模块[otel-simple-kafka](https://github.com/chenmudu/open-telemetry-java-guides/tree/master/otel-simple-kafka/src/main/java/org/chenmudu/otel/kafka)下的 KafkaMqMvcRunMain . | ||
|
||
3. 访问http://localhost:10008/kafkamq。 | ||
|
||
4. Copy Console 中的 TraceId访问 http://localhost:16686/ 即可观测结果。 |
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 @@ | ||
<?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-kafka</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.kafka</groupId> | ||
<artifactId>spring-kafka</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
31 changes: 31 additions & 0 deletions
31
otel-simple-kafka/src/main/java/org/chenmudu/otel/kafka/KafkaMqRunMain.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 @@ | ||
/** | ||
* MIT License | ||
* <p> | ||
* Copyright (c) 2020 chenmudu (陈晨) | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* <p> | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
package org.chenmudu.otel.kafka; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
/** | ||
* | ||
* @author [email protected] 2020/01/03 23:06 | ||
*/ | ||
@SpringBootApplication | ||
public class KafkaMqRunMain { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(KafkaMqRunMain.class, args); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
otel-simple-kafka/src/main/java/org/chenmudu/otel/kafka/common/CommonConstans.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,25 @@ | ||
/** | ||
* MIT License | ||
* <p> | ||
* Copyright (c) 2020 chenmudu (陈晨) | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* <p> | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
package org.chenmudu.otel.kafka.common; | ||
|
||
/** | ||
* | ||
* @author [email protected] 2021/1/3 16:01 | ||
*/ | ||
public class CommonConstans { | ||
|
||
public static final String TOPIC_NAME = "otel-test-topic"; | ||
} |
40 changes: 40 additions & 0 deletions
40
otel-simple-kafka/src/main/java/org/chenmudu/otel/kafka/consumer/KafkaMqConsume.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,40 @@ | ||
/** | ||
* MIT License | ||
* <p> | ||
* Copyright (c) 2020 chenmudu (陈晨) | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* <p> | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
package org.chenmudu.otel.kafka.consumer; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.chenmudu.otel.kafka.common.CommonConstans; | ||
import org.springframework.kafka.annotation.KafkaListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* | ||
* @author [email protected] 2021/1/3 16:05 | ||
*/ | ||
@Slf4j | ||
@Component | ||
public class KafkaMqConsume { | ||
|
||
/** | ||
* io.opentelemetry.auto.kafka-clients | ||
* @param content str msg. | ||
*/ | ||
@KafkaListener(topics = CommonConstans.TOPIC_NAME) | ||
public void processMessage(String content) { | ||
//consume message. | ||
log.info("KafkaMqConsume processMessage content msg : {}", content); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...imple-kafka/src/main/java/org/chenmudu/otel/kafka/controller/OtelTestKafkaController.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,41 @@ | ||
/** | ||
* MIT License | ||
* <p> | ||
* Copyright (c) 2020 chenmudu (陈晨) | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* <p> | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
package org.chenmudu.otel.kafka.controller; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.chenmudu.otel.kafka.producer.KafkaMqProducer; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* | ||
* @author [email protected] 2021/1/3 14:57 | ||
*/ | ||
@Slf4j | ||
@RestController | ||
public class OtelTestKafkaController { | ||
|
||
@Autowired | ||
private KafkaMqProducer kafkaMqProducer; | ||
|
||
@GetMapping("kafkamq") | ||
public String testKafkaMq() { | ||
log.info("OtelTestKafkaController testKafkaMq started!"); | ||
kafkaMqProducer.sendMessage(); | ||
return "hi,otel!"; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
otel-simple-kafka/src/main/java/org/chenmudu/otel/kafka/producer/KafkaMqProducer.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 @@ | ||
/** | ||
* MIT License | ||
* <p> | ||
* Copyright (c) 2020 chenmudu (陈晨) | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* <p> | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
*/ | ||
package org.chenmudu.otel.kafka.producer; | ||
|
||
import org.chenmudu.otel.kafka.common.CommonConstans; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.kafka.core.KafkaTemplate; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* | ||
* @author [email protected] 2021/1/3 16:04 | ||
*/ | ||
@Component | ||
public class KafkaMqProducer { | ||
|
||
@Autowired | ||
private KafkaTemplate template; | ||
|
||
/** | ||
* io.opentelemetry.auto.kafka-clients-0.11 | ||
*/ | ||
public void sendMessage() { | ||
template.send(CommonConstans.TOPIC_NAME, "hi, sofa tracer!"); | ||
} | ||
} |
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,7 @@ | ||
server.port=10008 | ||
|
||
spring.kafka.producer.bootstrap-servers=192.168.2.6:9092,192.168.2.6:9093 | ||
spring.kafka.consumer.group-id=data-otel-test | ||
spring.kafka.consumer.bootstrap-servers=192.168.2.6:9092,192.168.2.6:9093 | ||
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer | ||
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer |
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,15 @@ | ||
<configuration> | ||
<jmxConfigurator/> | ||
<property name="charset" value="UTF-8" /> | ||
<property name="pattern" | ||
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-5level] - [%X{traceId},%X{spanId}]- %logger{30}.%method:%line %msg%n" /> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>${pattern}</pattern> | ||
</encoder> | ||
</appender> | ||
<root level="INFO"> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
</configuration> |
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,13 @@ | ||
### Open-Telemetry-Simple-Rabbit 案例工程 | ||
|
||
> Open-Telemetry-Simple-Rabbit 实际测试了 Spring Amqp 以及 Rabbit Client。 | ||
##### 测试模块快速开始 | ||
|
||
1. 确保[Guides 案例工程下的步骤](../README.md)执行完毕。 | ||
|
||
2. 启动此模块[otel-simple-rabbit](https://github.com/chenmudu/open-telemetry-java-guides/tree/master/otel-simple-rabbit/src/main/java/org/chenmudu/otel/rabbit)下的 RabbitMqMvcRunMain . | ||
|
||
3. 访问http://localhost:10007/rabbitmq。 | ||
|
||
4. Copy Console 中的 TraceId访问 http://localhost:16686/ 即可观测结果。 |
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,32 @@ | ||
<?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> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>otel-simple-rabbitmq</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-amqp</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Oops, something went wrong.