This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 0b24a25e verify how skywalking connects to the micrometer (#724)
0b24a25e is described below
commit 0b24a25e23f4c2651833db85b6e095cd1097a792
Author: 叶梦飞 <[email protected]>
AuthorDate: Fri Feb 10 15:50:06 2023 +0800
verify how skywalking connects to the micrometer (#724)
* verify how skywalking connects to the micrometer
* verify how skywalking connects to the micrometer
---
.../README.md | 65 +++++++++
.../pom.xml | 92 +++++++++++++
.../skywalking/consumer/ConsumerApplication.java | 52 ++++++++
.../consumer/ObservationConfiguration.java | 46 +++++++
.../src/main/resources/application.yml | 38 ++++++
.../src/main/resources/log4j.properties | 22 ++++
.../pom.xml | 36 +++++
.../springboot/skywalking/demo/DemoService.java | 30 +++++
.../pom.xml | 87 ++++++++++++
.../skywalking/demo/provider/DemoServiceImpl.java | 38 ++++++
.../demo/provider/ObservationConfiguration.java | 44 +++++++
.../demo/provider/ProviderApplication.java | 34 +++++
.../src/main/resources/application.yml | 38 ++++++
.../src/main/resources/log4j.properties | 22 ++++
.../pom.xml | 146 +++++++++++++++++++++
.../skywalking-trace-result-1.png | Bin 0 -> 110335 bytes
.../skywalking-trace-result-2.png | Bin 0 -> 176769 bytes
.../skywalking-trace-result-3.png | Bin 0 -> 171298 bytes
4-governance/pom.xml | 1 +
19 files changed, 791 insertions(+)
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/README.md
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/README.md
new file mode 100644
index 00000000..36e96122
--- /dev/null
+++ b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/README.md
@@ -0,0 +1,65 @@
+# Overview
+Apache Dubbo has inbuilt tracing through [Micrometer
Observations](https://micrometer.io/)
+and [Micrometer Tracing](https://github.com/micrometer-metrics/tracing).
+And the micrometer can integrate with skywalking by [skywalking
micrometer-1.10
api](https://skywalking.apache.org/docs/skywalking-java/next/en/setup/service-agent/java-agent/application-toolkit-micrometer-1.10/).
+
+## 1. Adding Micrometer Observation To Your Project
+In order to add Micrometer to the classpath and add metrics for Dubbo you need
to add the `dubbo-metrics-api` dependency
+as shown below:
+```xml
+
+<dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-metrics-api</artifactId>
+</dependency>
+```
+
+## 2. Add Skywalking Micrometer-1.10 Api To Your Project
+To integrate the dubbo's micrometer tracing data to skywalking, you should add
this toolkit dependency.
+```xml
+<dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>apm-toolkit-micrometer-1.10</artifactId>
+</dependency>
+```
+
+## 3. Configuration ObservationRegistry
+```java
+@Configuration
+public class ObservationConfiguration {
+ @Bean
+ ApplicationModel applicationModel(ObservationRegistry observationRegistry)
{
+ ApplicationModel applicationModel = ApplicationModel.defaultModel();
+ observationRegistry.observationConfig()
+ .observationHandler(new
ObservationHandler.FirstMatchingCompositeObservationHandler(
+ new SkywalkingSenderTracingHandler(), new
SkywalkingReceiverTracingHandler(),
+ new SkywalkingDefaultTracingHandler()
+ ));
+ applicationModel.getBeanFactory().registerBean(observationRegistry);
+ return applicationModel;
+ }
+}
+```
+## 4. Start the Skywalking OAP
+[skywalking oap
setup](https://skywalking.apache.org/docs/main/v9.3.0/en/setup/backend/backend-setup/)
+```shell
+bash startup.sh
+```
+## 5. Start Provider and Application With Skywalking Agent
+After starting the registration center, we start provider and Consumer with
skywalking agent, so skywalking can report trace data.
+And because skywalking java agent have instrumented the dubbo and spring
framework, to verify dubbo integrates with skywalking by micrometer,
+**we should delete plugin jars in "plugins" directory**.
+To connect the skywalking oap, we should config the backend address in
/path/to/skywalking-agent/agent.config.
+The relevant field is **collector.backend_service**.
+```shell
+java -javaagent:/path/to/skywalking-agent/skywalking-agent.jar -jar
dubbo-samples-spring-boot-tracing-skwalking-provider-1.0-SNAPSHOT.jar
+```
+```shell
+java -javaagent:/path/to/skywalking-agent/skywalking-agent.jar -jar
dubbo-samples-spring-boot-tracing-skwalking-consumer-1.0-SNAPSHOT.jar
+```
+## 6. Result
+Open [skywalking-webapp](http://localhost:8080/) in browser.
+
+
+
+
\ No newline at end of file
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/pom.xml
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/pom.xml
new file mode 100644
index 00000000..731f8a82
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/pom.xml
@@ -0,0 +1,92 @@
+<?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.dubbo</groupId>
+ <artifactId>dubbo-samples-spring-boot-tracing-skywalking</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+
<artifactId>dubbo-samples-spring-boot-tracing-skwalking-consumer</artifactId>
+
+ <properties>
+ <maven.compiler.source>17</maven.compiler.source>
+ <maven.compiler.target>17</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+
<artifactId>dubbo-samples-spring-boot-tracing-skwalking-interface</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <!-- registry dependency -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ </dependency>
+
+ <!-- dubbo starter -->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ </dependency>
+
+ <!-- spring starter -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <!-- Observabililty -->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-metrics-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>apm-toolkit-micrometer-1.10</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/java/org/apache/dubbo/springboot/skywalking/consumer/ConsumerApplication.java
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/java/org/apache/dubbo/springboot/skywalking/consumer/ConsumerApplication.java
new file mode 100644
index 00000000..1854846e
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/java/org/apache/dubbo/springboot/skywalking/consumer/ConsumerApplication.java
@@ -0,0 +1,52 @@
+/*
+ * 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.dubbo.springboot.skywalking.consumer;
+
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.apache.dubbo.springboot.skywalking.demo.DemoService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.stereotype.Service;
+
+@SpringBootApplication
+@Service
+@EnableDubbo
+public class ConsumerApplication {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ConsumerApplication.class);
+
+ @DubboReference
+ private DemoService demoService;
+
+ public static void main(String[] args) {
+ ConfigurableApplicationContext context =
SpringApplication.run(ConsumerApplication.class, args);
+ ConsumerApplication application =
context.getBean(ConsumerApplication.class);
+ String result = application.doSayHello("world");
+ LOGGER.info("result: {}", result);
+ }
+
+ public String doSayHello(String name) {
+ return demoService.sayHello(name);
+ }
+
+}
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/java/org/apache/dubbo/springboot/skywalking/consumer/ObservationConfiguration.java
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/java/org/apache/dubbo/springboot/skywalking/consumer/ObservationConfiguration.java
new file mode 100644
index 00000000..f3ce46ca
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/java/org/apache/dubbo/springboot/skywalking/consumer/ObservationConfiguration.java
@@ -0,0 +1,46 @@
+/*
+ * 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.dubbo.springboot.skywalking.consumer;
+
+import io.micrometer.observation.ObservationHandler;
+import io.micrometer.observation.ObservationRegistry;
+
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+import
org.apache.skywalking.apm.toolkit.micrometer.observation.SkywalkingDefaultTracingHandler;
+import
org.apache.skywalking.apm.toolkit.micrometer.observation.SkywalkingReceiverTracingHandler;
+import
org.apache.skywalking.apm.toolkit.micrometer.observation.SkywalkingSenderTracingHandler;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+@Configuration
+public class ObservationConfiguration {
+ @Bean
+ ApplicationModel applicationModel(ObservationRegistry observationRegistry)
{
+ ApplicationModel applicationModel = ApplicationModel.defaultModel();
+ observationRegistry.observationConfig()
+ .observationHandler(new
ObservationHandler.FirstMatchingCompositeObservationHandler(
+ new SkywalkingSenderTracingHandler(), new
SkywalkingReceiverTracingHandler(),
+ new SkywalkingDefaultTracingHandler()
+ ));
+ applicationModel.getBeanFactory().registerBean(observationRegistry);
+ return applicationModel;
+ }
+}
+
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/resources/application.yml
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/resources/application.yml
new file mode 100644
index 00000000..632e0f65
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/resources/application.yml
@@ -0,0 +1,38 @@
+# 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.
+
+spring:
+ application:
+ name: dubbo-springboot-skywalking-demo-consumer
+
+management:
+ tracing:
+ sampling:
+ probability: 1.0
+
+dubbo:
+ application:
+ name: ${spring.application.name}
+ protocol:
+ name: dubbo
+ port: -1
+ registry:
+ id: nacos-registry
+ address: nacos://127.0.0.1:8848
+ config-center:
+ address: nacos://127.0.0.1:8848
+ metadata-report:
+ address: nacos://127.0.0.1:8848
\ No newline at end of file
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/resources/log4j.properties
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/resources/log4j.properties
new file mode 100644
index 00000000..eb052e32
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-consumer/src/main/resources/log4j.properties
@@ -0,0 +1,22 @@
+# 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.
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}]
%t %5p %c{2}: %m%n
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-interface/pom.xml
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-interface/pom.xml
new file mode 100644
index 00000000..30a3a4e7
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-interface/pom.xml
@@ -0,0 +1,36 @@
+<?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.dubbo</groupId>
+ <artifactId>dubbo-samples-spring-boot-tracing-skywalking</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+
<artifactId>dubbo-samples-spring-boot-tracing-skwalking-interface</artifactId>
+
+ <properties>
+ <maven.compiler.source>17</maven.compiler.source>
+ <maven.compiler.target>17</maven.compiler.target>
+ </properties>
+
+</project>
\ No newline at end of file
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-interface/src/main/java/org/apache/dubbo/springboot/skywalking/demo/DemoService.java
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-interface/src/main/java/org/apache/dubbo/springboot/skywalking/demo/DemoService.java
new file mode 100644
index 00000000..5dbc4788
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-interface/src/main/java/org/apache/dubbo/springboot/skywalking/demo/DemoService.java
@@ -0,0 +1,30 @@
+/*
+ * 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.dubbo.springboot.skywalking.demo;
+
+import java.util.concurrent.CompletableFuture;
+
+public interface DemoService {
+
+ String sayHello(String name);
+
+ default CompletableFuture<String> sayHelloAsync(String name) {
+ return CompletableFuture.completedFuture(sayHello(name));
+ }
+
+}
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/pom.xml
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/pom.xml
new file mode 100644
index 00000000..0bc5f8ea
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/pom.xml
@@ -0,0 +1,87 @@
+<?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.dubbo</groupId>
+ <artifactId>dubbo-samples-spring-boot-tracing-skywalking</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+
<artifactId>dubbo-samples-spring-boot-tracing-skwalking-provider</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+
<artifactId>dubbo-samples-spring-boot-tracing-skwalking-interface</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+
+ <!-- registry dependency -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ </dependency>
+
+ <!-- dubbo starter -->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ </dependency>
+
+ <!-- spring starter -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <!-- Observabililty -->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-metrics-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>apm-toolkit-micrometer-1.10</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/DemoServiceImpl.java
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/DemoServiceImpl.java
new file mode 100644
index 00000000..9cfa1a00
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/DemoServiceImpl.java
@@ -0,0 +1,38 @@
+/*
+ * 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.dubbo.springboot.skywalking.demo.provider;
+
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.springboot.skywalking.demo.DemoService;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@DubboService
+public class DemoServiceImpl implements DemoService {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(DemoServiceImpl.class);
+
+ @Override
+ public String sayHello(String name) {
+ LOGGER.info("Hello {}, request from consumer: {}", name,
RpcContext.getContext().getRemoteAddress());
+ return "Hello " + name;
+ }
+
+}
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/ObservationConfiguration.java
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/ObservationConfiguration.java
new file mode 100644
index 00000000..ef81645f
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/ObservationConfiguration.java
@@ -0,0 +1,44 @@
+/*
+ * 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.dubbo.springboot.skywalking.demo.provider;
+
+import io.micrometer.observation.ObservationHandler;
+import io.micrometer.observation.ObservationRegistry;
+
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+import
org.apache.skywalking.apm.toolkit.micrometer.observation.SkywalkingDefaultTracingHandler;
+import
org.apache.skywalking.apm.toolkit.micrometer.observation.SkywalkingReceiverTracingHandler;
+import
org.apache.skywalking.apm.toolkit.micrometer.observation.SkywalkingSenderTracingHandler;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ObservationConfiguration {
+ @Bean
+ ApplicationModel applicationModel(ObservationRegistry observationRegistry)
{
+ ApplicationModel applicationModel = ApplicationModel.defaultModel();
+ observationRegistry.observationConfig()
+ .observationHandler(new
ObservationHandler.FirstMatchingCompositeObservationHandler(
+ new SkywalkingSenderTracingHandler(), new
SkywalkingReceiverTracingHandler(),
+ new SkywalkingDefaultTracingHandler()
+ ));
+ applicationModel.getBeanFactory().registerBean(observationRegistry);
+ return applicationModel;
+ }
+}
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/ProviderApplication.java
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/ProviderApplication.java
new file mode 100644
index 00000000..a4ca48b9
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/java/org/apache/dubbo/springboot/skywalking/demo/provider/ProviderApplication.java
@@ -0,0 +1,34 @@
+/*
+ * 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.dubbo.springboot.skywalking.demo.provider;
+
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@EnableDubbo
+public class ProviderApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ProviderApplication.class, args);
+ System.out.println("dubbo service started");
+ }
+
+}
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/resources/application.yml
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/resources/application.yml
new file mode 100644
index 00000000..5d13f821
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/resources/application.yml
@@ -0,0 +1,38 @@
+# 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.
+
+spring:
+ application:
+ name: dubbo-springboot-skywalking-demo-provider
+
+management:
+ tracing:
+ sampling:
+ probability: 1.0
+
+dubbo:
+ application:
+ name: ${spring.application.name}
+ protocol:
+ name: dubbo
+ port: -1
+ registry:
+ id: nacos-registry
+ address: nacos://127.0.0.1:8848
+ config-center:
+ address: nacos://127.0.0.1:8848
+ metadata-report:
+ address: nacos://127.0.0.1:8848
\ No newline at end of file
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/resources/log4j.properties
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/resources/log4j.properties
new file mode 100644
index 00000000..eb052e32
--- /dev/null
+++
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/dubbo-samples-spring-boot-tracing-skwalking-provider/src/main/resources/log4j.properties
@@ -0,0 +1,22 @@
+# 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.
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}]
%t %5p %c{2}: %m%n
diff --git a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/pom.xml
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/pom.xml
new file mode 100644
index 00000000..68186586
--- /dev/null
+++ b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/pom.xml
@@ -0,0 +1,146 @@
+<?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</groupId>
+ <artifactId>apache</artifactId>
+ <version>23</version>
+ <relativePath/>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-spring-boot-tracing-skywalking</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <packaging>pom</packaging>
+ <name>Dubbo Samples SpringBoot Tracing Skywalking</name>
+ <description>Dubbo Samples SpringBoot Tracing Skywalking</description>
+ <modules>
+ <module>dubbo-samples-spring-boot-tracing-skwalking-provider</module>
+ <module>dubbo-samples-spring-boot-tracing-skwalking-consumer</module>
+ <module>dubbo-samples-spring-boot-tracing-skwalking-interface</module>
+ </modules>
+
+ <properties>
+ <maven.compiler.source>17</maven.compiler.source>
+ <maven.compiler.target>17</maven.compiler.target>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <java.version>17</java.version>
+ <dubbo.version>3.2.0-beta.4-SNAPSHOT</dubbo.version>
+ <nacos.version>2.2.0</nacos.version>
+ <micrometer.version>1.10.3</micrometer.version>
+ <micrometer-tracing.version>1.0.1</micrometer-tracing.version>
+ <opentelemetry.version>1.1.0</opentelemetry.version>
+ <junit.version>4.13.1</junit.version>
+ <slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
+ <spring-boot.version>3.0.2</spring-boot.version>
+
<spring-boot-maven-plugin.version>2.6.8</spring-boot-maven-plugin.version>
+ <skywalking-agent.version>8.14.0</skywalking-agent.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Spring Boot -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${spring-boot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ <version>${nacos.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-bom</artifactId>
+ <version>${micrometer.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-tracing-bom</artifactId>
+ <version>${micrometer-tracing.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.skywalking</groupId>
+ <artifactId>apm-toolkit-micrometer-1.10</artifactId>
+ <version>${skywalking-agent.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-log4j12.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-1.png
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-1.png
new file mode 100644
index 00000000..1dd70352
Binary files /dev/null and
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-1.png
differ
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-2.png
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-2.png
new file mode 100644
index 00000000..3679e7f5
Binary files /dev/null and
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-2.png
differ
diff --git
a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-3.png
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-3.png
new file mode 100644
index 00000000..59cb43e3
Binary files /dev/null and
b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/skywalking-trace-result-3.png
differ
diff --git a/4-governance/pom.xml b/4-governance/pom.xml
index 22f53f3b..a6c00e1f 100644
--- a/4-governance/pom.xml
+++ b/4-governance/pom.xml
@@ -43,5 +43,6 @@
<module>dubbo-samples-tracing</module>
<module>dubbo-samples-zipkin</module>
<module>dubbo-samples-spring-boot3-tracing</module>
+ <module>dubbo-samples-spring-boot-tracing-skywalking</module>
</modules>
</project>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]