You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2022/01/06 09:10:12 UTC
[incubator-shenyu] branch master updated: Init integration test for opentelemetry plugin of shenyu-agent (#2718)
This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new b744bad Init integration test for opentelemetry plugin of shenyu-agent (#2718)
b744bad is described below
commit b744bad68ff6c723921c7d18419452650dc6b93a
Author: Kunshuai Zhu <jo...@gmail.com>
AuthorDate: Thu Jan 6 17:10:07 2022 +0800
Init integration test for opentelemetry plugin of shenyu-agent (#2718)
* Init integration test for shenyu-agent
* Refactor module structure
* Add sleep time
* remove unused
* fix
---
.../workflows/integrated-test-agent-tracing.yml | 76 +++++++
shenyu-integrated-test/pom.xml | 1 +
.../shenyu-integrated-test-agent/pom.xml | 43 ++++
.../shenyu-integrated-test-agent-tracing/pom.xml | 35 ++++
.../Dockerfile | 27 +++
.../docker-compose.yml | 90 +++++++++
.../pom.xml | 108 ++++++++++
.../script/healthcheck.sh | 36 ++++
.../script/services.list | 19 ++
.../src/main/assembly/binary.xml | 90 +++++++++
.../OpenTelemetryIntegratedBootstrap.java | 37 ++++
.../src/main/resources/application.yml | 53 +++++
.../src/main/resources/bin/start.sh | 65 ++++++
.../src/main/resources/bin/stop.sh | 51 +++++
.../src/main/resources/conf/logback.xml | 33 +++
.../src/main/resources/conf/shenyu-agent.yaml | 44 ++++
.../src/main/resources/conf/tracing-point.yaml | 221 +++++++++++++++++++++
.../opentelemetry/OpenTelemetryPluginTest.java | 94 +++++++++
.../agent/opentelemetry/result/JaegerSpan.java | 148 ++++++++++++++
.../integratedtest/common/helper/HttpHelper.java | 21 +-
20 files changed, 1285 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/integrated-test-agent-tracing.yml b/.github/workflows/integrated-test-agent-tracing.yml
new file mode 100644
index 0000000..013d16e
--- /dev/null
+++ b/.github/workflows/integrated-test-agent-tracing.yml
@@ -0,0 +1,76 @@
+# 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.
+
+name: it-agent-tracing
+
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ case:
+ - shenyu-integrated-test-agent-tracing-opentelemetry
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: Set Skip Env Var
+ uses: ./.github/actions/skip-ci
+ - name: Cache Maven Repos
+ if: env.SKIP_CI != 'true'
+ uses: actions/cache@v2
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
+ - uses: actions/setup-java@v1
+ if: env.SKIP_CI != 'true'
+ with:
+ java-version: 8
+ - name: Build with Maven
+ if: env.SKIP_CI != 'true'
+ run: ./mvnw -B clean install -Prelease,docker -Dmaven.javadoc.skip=true -Dmaven.test.skip=true
+ - name: Build integrated tests for agent
+ if: env.SKIP_CI != 'true'
+ run: ./mvnw -B clean install -Pit4a -DskipTests -f ./shenyu-integrated-test/pom.xml
+ - name: Start docker compose
+ if: env.SKIP_CI != 'true'
+ run: docker-compose -f ./shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/${{ matrix.case }}/docker-compose.yml up -d
+ - name: Wait for docker compose start up completely
+ if: env.SKIP_CI != 'true'
+ run: bash ./shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/${{ matrix.case }}/script/healthcheck.sh
+ - name: Run test
+ id: test
+ if: env.SKIP_CI != 'true'
+ run: ./mvnw test -Ptest -f ./shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/${{ matrix.case }}/pom.xml
+ continue-on-error: true
+ - name: Check test result
+ if: env.SKIP_CI != 'true'
+ run: |
+ docker-compose -f ./shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/${{ matrix.case }}/docker-compose.yml logs --tail="all"
+ if [[ ${{steps.test.outcome}} == "failure" ]]; then
+ echo "Test Failed"
+ exit 1
+ else
+ echo "Test Successful"
+ exit 0
+ fi
diff --git a/shenyu-integrated-test/pom.xml b/shenyu-integrated-test/pom.xml
index 589119b..6ec95b9 100644
--- a/shenyu-integrated-test/pom.xml
+++ b/shenyu-integrated-test/pom.xml
@@ -40,6 +40,7 @@
<module>shenyu-integrated-test-sofa</module>
<module>shenyu-integrated-test-websocket</module>
<module>shenyu-integrated-test-combination</module>
+ <module>shenyu-integrated-test-agent</module>
</modules>
<properties>
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/pom.xml b/shenyu-integrated-test/shenyu-integrated-test-agent/pom.xml
new file mode 100644
index 0000000..5d5e57d
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/pom.xml
@@ -0,0 +1,43 @@
+<?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>
+ <artifactId>shenyu-integrated-test</artifactId>
+ <groupId>org.apache.shenyu</groupId>
+ <version>2.4.2-SNAPSHOT</version>
+ </parent>
+ <packaging>pom</packaging>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>shenyu-integrated-test-agent</artifactId>
+
+ <modules>
+ <module>shenyu-integrated-test-agent-tracing</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-integrated-test-common</artifactId>
+ <version>${shenyu.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/pom.xml b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/pom.xml
new file mode 100644
index 0000000..3adce4d
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/pom.xml
@@ -0,0 +1,35 @@
+<?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>
+ <artifactId>shenyu-integrated-test-agent</artifactId>
+ <groupId>org.apache.shenyu</groupId>
+ <version>2.4.2-SNAPSHOT</version>
+ </parent>
+ <packaging>pom</packaging>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>shenyu-integrated-test-agent-tracing</artifactId>
+
+ <modules>
+ <module>shenyu-integrated-test-agent-tracing-opentelemetry</module>
+ </modules>
+
+</project>
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/Dockerfile b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/Dockerfile
new file mode 100644
index 0000000..dd84d12
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/Dockerfile
@@ -0,0 +1,27 @@
+# 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.
+
+FROM openjdk:8
+
+ENV APP_NAME shenyu-integrated-test-agent-tracing-opentelemetry
+ENV LOCAL_PATH /opt/${APP_NAME}
+
+ADD target/${APP_NAME} ${LOCAL_PATH}
+
+WORKDIR ${LOCAL_PATH}
+EXPOSE 9195
+
+CMD ${LOCAL_PATH}/bin/start.sh agent && tail -f ${LOCAL_PATH}/logs/shenyu-bootstrap.log
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/docker-compose.yml b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/docker-compose.yml
new file mode 100644
index 0000000..9d8c384
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/docker-compose.yml
@@ -0,0 +1,90 @@
+# 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.
+version: "3.9"
+services:
+ shenyu-jaeger:
+ image: "jaegertracing/all-in-one:latest"
+ container_name: shenyu-jaeger
+ restart: always
+ networks:
+ - shenyu
+ ports:
+ - "16686:16686"
+
+ shenyu-admin:
+ image: apache/shenyu-admin:latest
+ container_name: shenyu-admin
+ restart: always
+ networks:
+ - shenyu
+ ports:
+ - "9095:9095"
+ environment:
+ - SPRING_PROFILES_ACTIVE=h2
+ - shenyu.database.init_script=sql-script/h2/schema.sql
+ healthcheck:
+ test: [ "CMD-SHELL", "wget -q -O - http://shenyu-admin:9095/actuator/health | grep UP || exit 1" ]
+ timeout: 2s
+ retries: 30
+ depends_on:
+ - shenyu-jaeger
+
+ shenyu-integrated-test-agent-tracing-opentelemetry:
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ container_name: shenyu-integrated-test-agent-tracing-opentelemetry
+ image: apache/shenyu-integrated-test-agent-tracing-opentelemetry:latest
+ restart: always
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ ports:
+ - "9195:9195"
+ networks:
+ - shenyu
+ healthcheck:
+ test: [ "CMD", "wget", "http://shenyu-integrated-test-agent-tracing-opentelemetry:9195/actuator/health" ]
+ timeout: 2s
+ retries: 30
+
+ shenyu-examples-http:
+ deploy:
+ resources:
+ limits:
+ memory: 2048M
+ container_name: shenyu-examples-http
+ image: shenyu-examples-http:latest
+ restart: always
+ environment:
+ - shenyu.register.serverLists=http://shenyu-admin:9095
+ healthcheck:
+ test: [ "CMD", "wget", "http://shenyu-examples-http:8189/test/path/123?name=tom" ]
+ timeout: 2s
+ retries: 30
+ ports:
+ - "8189:8189"
+ depends_on:
+ shenyu-admin:
+ condition: service_healthy
+ networks:
+ - shenyu
+
+networks:
+ shenyu:
+ name: shenyu
+ driver: bridge
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/pom.xml b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/pom.xml
new file mode 100644
index 0000000..b0fe5f5
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/pom.xml
@@ -0,0 +1,108 @@
+<?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.shenyu</groupId>
+ <artifactId>shenyu-integrated-test-agent-tracing</artifactId>
+ <version>2.4.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>shenyu-integrated-test-agent-tracing-opentelemetry</artifactId>
+ <name>shenyu-integrated-test-agent-tracing-opentelemetry</name>
+ <url>https://shenyu.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-spring-boot-starter-plugin-divide</artifactId>
+ <version>${shenyu.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>shenyu-integrated-test-agent-tracing-opentelemetry</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/binary.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ <executions>
+ <execution>
+ <id>bin</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>it4a</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>${dockerfile-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>shenyu-integrated-test-agent-tracing-opentelemetry</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <repository>apache/shenyu-integrated-test-agent-tracing-opentelemetry</repository>
+ <tag>latest</tag>
+ <buildArgs>
+ <APP_NAME>shenyu-integrated-test-agent-tracing-opentelemetry</APP_NAME>
+ </buildArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>test</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>false</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/script/healthcheck.sh b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/script/healthcheck.sh
new file mode 100644
index 0000000..22a7603
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/script/healthcheck.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# 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.
+#
+
+PRGDIR=`dirname "$0"`
+for service in `grep -v -E "^$|^#" ${PRGDIR}/services.list`
+do
+ for loop in `seq 1 30`
+ do
+ status=`curl -o /dev/null -s -w %{http_code} $service`
+ echo -e "curl $service response $status"
+
+ if [ $status -eq 200 ]; then
+ break
+ fi
+
+ sleep 2
+ done
+done
+
+sleep 3
+echo -e "\n-------------------"
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/script/services.list b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/script/services.list
new file mode 100644
index 0000000..e48dc7e
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/script/services.list
@@ -0,0 +1,19 @@
+# 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.
+
+http://localhost:9095/actuator/health
+http://localhost:8189/test/path/123?name=tom
+http://localhost:9195/actuator/health
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/assembly/binary.xml b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/assembly/binary.xml
new file mode 100644
index 0000000..87a1a82
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/assembly/binary.xml
@@ -0,0 +1,90 @@
+<!--
+ ~ 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.
+ -->
+
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
+ <id>bin</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>src/main/resources</directory>
+ <lineEnding>unix</lineEnding>
+ <includes>
+ <include>*.xml</include>
+ </includes>
+ <outputDirectory>conf</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>*.yml</include>
+ </includes>
+ <outputDirectory>conf</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources/bin</directory>
+ <lineEnding>unix</lineEnding>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <outputDirectory>ext-lib</outputDirectory>
+ <excludes>
+ <exclude>**/*</exclude>
+ </excludes>
+ </fileSet>
+
+ <!-- agent -->
+ <fileSet>
+ <directory>${project.basedir}/../../../../shenyu-agent/target</directory>
+ <includes>
+ <include>shenyu-agent.jar</include>
+ </includes>
+ <outputDirectory>agent</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/../../../../shenyu-agent/shenyu-agent-plugins/shenyu-agent-plugin-tracing/target/plugins</directory>
+ <outputDirectory>agent/plugins</outputDirectory>
+ <includes>
+ <include>shenyu-agent-plugin-tracing-common-*.jar</include>
+ <include>shenyu-agent-plugin-tracing-opentelemetry-*.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources/conf</directory>
+ <includes>
+ <include>*.yaml</include>
+ </includes>
+ <outputDirectory>agent/conf</outputDirectory>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ <fileMode>0644</fileMode>
+ </dependencySet>
+ </dependencySets>
+</assembly>
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/java/org/apache/shenyu/integrated/test/agent/opentelemetry/OpenTelemetryIntegratedBootstrap.java b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/java/org/apache/shenyu/integrated/test/agent/opentelemetry/OpenTelemetryIntegratedB [...]
new file mode 100644
index 0000000..b0aefc5
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/java/org/apache/shenyu/integrated/test/agent/opentelemetry/OpenTelemetryIntegratedBootstrap.java
@@ -0,0 +1,37 @@
+/*
+ * 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.shenyu.integrated.test.agent.opentelemetry;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * The OpenTelemetry plugin of agent integrated bootstrap.
+ */
+@SpringBootApplication
+public class OpenTelemetryIntegratedBootstrap {
+
+ /**
+ * main method of App.
+ *
+ * @param args args
+ */
+ public static void main(final String[] args) {
+ SpringApplication.run(OpenTelemetryIntegratedBootstrap.class);
+ }
+}
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/application.yml b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/application.yml
new file mode 100644
index 0000000..c35f578
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/application.yml
@@ -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.
+
+server:
+ port: 9195
+ address: 0.0.0.0
+
+spring:
+ main:
+ allow-bean-definition-overriding: true
+ application:
+ name: shenyu-bootstrap
+
+management:
+ health:
+ defaults:
+ enabled: false
+
+shenyu:
+ switchConfig:
+ local: true
+ cross:
+ enabled: true
+ sync:
+ websocket:
+ urls: ws://shenyu-admin:9095/websocket
+ exclude:
+ enabled: true
+ paths:
+ - /favicon.ico
+ - /actuator/health
+
+logging:
+ level:
+ root: info
+ org.springframework.boot: info
+ org.apache.ibatis: info
+ org.apache.shenyu.bonuspoint: info
+ org.apache.shenyu.lottery: info
+ org.apache.shenyu: info
+
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/bin/start.sh b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/bin/start.sh
new file mode 100644
index 0000000..7b022b3
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/bin/start.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+# 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.
+#
+
+SERVER_NAME=ShenYu-Bootstrap
+
+cd `dirname $0`
+cd ..
+DEPLOY_DIR=`pwd`
+
+LOGS_DIR=${DEPLOY_DIR}/logs
+if [ ! -d ${LOGS_DIR} ]; then
+ mkdir ${LOGS_DIR}
+fi
+
+LOG_FILES=${LOGS_DIR}/shenyu-bootstrap.log
+EXT_LIB=${DEPLOY_DIR}/ext-lib
+
+PIDS=`ps -ef | grep "$DEPLOY_DIR" | grep -v grep | pgrep -f java`
+if [ -n "$PIDS" ]; then
+ echo "ERROR: The $SERVER_NAME already started!"
+ echo "PID: $PIDS"
+ exit 1
+fi
+
+CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*
+JAVA_OPTS=" -server -Xmx2g -Xms2g -Xmn1g -Xss512k -XX:+DisableExplicitGC -XX:LargePageSizeInBytes=128m"
+
+version=`java -version 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $3}'`
+echo "current jdk version:${version}"
+if [[ "$version" =~ "1.8" ]];then
+JAVA_OPTS="${JAVA_OPTS} -XX:+UseFastAccessorMethods -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70"
+elif [[ "$version" =~ "11" ]];then
+JAVA_OPTS="${JAVA_OPTS}"
+elif [[ "$version" =~ "17" ]];then
+JAVA_OPTS="${JAVA_OPTS}"
+fi
+
+MAIN_CLASS=org.apache.shenyu.integrated.test.agent.opentelemetry.OpenTelemetryIntegratedBootstrap
+
+if [[ "$1" == "agent" ]]; then
+ echo "Starting the $SERVER_NAME with shenyu-agent ..."
+ SHENYU_AGENT=${DEPLOY_DIR}/agent/shenyu-agent.jar
+ nohup java ${JAVA_OPTS} -javaagent:${SHENYU_AGENT} -classpath ${CLASS_PATH} ${MAIN_CLASS} >> ${LOG_FILES} 2>&1 &
+else
+ echo "Starting the $SERVER_NAME ..."
+ nohup java ${JAVA_OPTS} -classpath ${CLASS_PATH} ${MAIN_CLASS} >> ${LOG_FILES} 2>&1 &
+fi
+
+sleep 1
+echo "Please check the log files: $LOG_FILES"
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/bin/stop.sh b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/bin/stop.sh
new file mode 100644
index 0000000..73599d2
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/bin/stop.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# 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.
+#
+
+SERVER_NAME=ShenYu-Bootstrap
+
+cd `dirname $0`
+cd ..
+DEPLOY_DIR=`pwd`
+
+PIDS=`ps -ef | grep "$DEPLOY_DIR" | grep -v grep | pgrep -f java`
+if [ -z "$PIDS" ]; then
+ echo "ERROR: The $SERVER_NAME does not started!"
+ exit 1
+fi
+
+echo -e "Stopping the $SERVER_NAME ...\c"
+for PID in ${PIDS} ; do
+ kill ${PID} > /dev/null 2>&1
+done
+
+COUNT=0
+while [ ${COUNT} -lt 1 ]; do
+ echo -e ".\c"
+ sleep 1
+ COUNT=1
+ for PID in ${PIDS} ; do
+ PID_EXIST=`ps -f -p ${PID} | grep java`
+ if [ -n "$PID_EXIST" ]; then
+ COUNT=0
+ break
+ fi
+ done
+done
+
+echo "OK!"
+echo "PID: $PIDS"
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/logback.xml b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/logback.xml
new file mode 100644
index 0000000..41d80cd
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/logback.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+ -->
+
+<configuration>
+ <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <logger name="org.apache.shenyu" level="info" additivity="false">
+ <appender-ref ref="console" />
+ </logger>
+
+ <root>
+ <level value="info" />
+ <appender-ref ref="console" />
+ </root>
+</configuration>
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/shenyu-agent.yaml b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/shenyu-agent.yaml
new file mode 100644
index 0000000..40ad45b
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/shenyu-agent.yaml
@@ -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.
+#
+
+appName: shenyu-agent
+supports:
+ tracing:
+ - opentelemetry
+
+plugins:
+ tracing:
+ jaeger:
+ host: "localhost"
+ port: 5775
+ props:
+ SERVICE_NAME: "shenyu-agent"
+ JAEGER_SAMPLER_TYPE: "const"
+ JAEGER_SAMPLER_PARAM: "1"
+ opentelemetry:
+ props:
+ otel.traces.exporter: jaeger #zipkin #otlp
+ otel.resource.attributes: "service.name=shenyu-agent"
+ otel.exporter.jaeger.endpoint: "http://shenyu-jaeger:14250/api/traces"
+ zipkin:
+ host: "localhost"
+ port: 9411
+ props:
+ SERVICE_NAME: "shenyu-agent"
+ URL_VERSION: "/api/v2/spans"
+ SAMPLER_TYPE: "const"
+ SAMPLER_PARAM: "1"
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/tracing-point.yaml b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/tracing-point.yaml
new file mode 100644
index 0000000..403c8a7
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/main/resources/conf/tracing-point.yaml
@@ -0,0 +1,221 @@
+#
+# 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.
+#
+
+pointCuts:
+ - targetClass: org.apache.shenyu.plugin.global.GlobalPlugin
+ points:
+ - type: instanceMethod
+ name: execute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryGlobalPluginHandler
+ - targetClass: org.apache.shenyu.plugin.context.path.ContextPathPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.divide.DividePlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.alibaba.dubbo.AlibabaDubboPlugin
+ points:
+ - type: instanceMethod
+ name: doDubboInvoker
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.apache.dubbo.ApacheDubboPlugin
+ points:
+ - type: instanceMethod
+ name: doDubboInvoker
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.general.context.GeneralContextPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.grpc.GrpcPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.hystrix.HystrixPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.jwt.JwtPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.logging.LoggingPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.modify.response.ModifyResponsePlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.monitor.MonitorPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.motan.MotanPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.oauth2.OAuth2Plugin
+ points:
+ - type: instanceMethod
+ name: execute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.param.mapping.ParamMappingPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.ratelimiter.RateLimiterPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.redirect.RedirectPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.request.RequestPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.resilience4j.Resilience4JPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.response.ResponsePlugin
+ points:
+ - type: instanceMethod
+ name: execute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.rewrite.RewritePlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.sentinel.SentinelPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.sign.SignPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.sofa.SofaPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.springcloud.SpringCloudPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.tars.TarsPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.uri.URIPlugin
+ points:
+ - type: instanceMethod
+ name: execute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.waf.WafPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
+ - targetClass: org.apache.shenyu.plugin.websocket.WebSocketPlugin
+ points:
+ - type: instanceMethod
+ name: doExecute
+ handlers:
+ opentelemetry:
+ - org.apache.shenyu.agent.plugin.tracing.opentelemetry.handler.OpenTelemetryPluginCommonHandler
\ No newline at end of file
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/test/java/org/apache/shenyu/integrated/test/agent/opentelemetry/OpenTelemetryPluginTest.java b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/test/java/org/apache/shenyu/integrated/test/agent/opentelemetry/OpenTelemetryPluginTest.java
new file mode 100644
index 0000000..77408b7
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/test/java/org/apache/shenyu/integrated/test/agent/opentelemetry/OpenTelemetryPluginTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.shenyu.integrated.test.agent.opentelemetry;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonParser;
+import org.apache.shenyu.integrated.test.agent.opentelemetry.result.JaegerSpan;
+import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
+import org.apache.shenyu.integratedtest.common.dto.OrderDTO;
+import org.apache.shenyu.integratedtest.common.helper.HttpHelper;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Test for tracing OpenTelemetry plugin.
+ */
+public final class OpenTelemetryPluginTest extends AbstractPluginDataInit {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OpenTelemetryPluginTest.class);
+
+ private static final String JAEGER_HTTP_SERVER = "http://localhost:16686/api/traces?service=shenyu-agent";
+
+ private static final Gson GSON = new Gson();
+
+ @BeforeClass
+ public static void setup() throws IOException, InterruptedException {
+ OrderDTO user = new OrderDTO("123", "Tom");
+ user = HttpHelper.INSTANCE.postGateway("/http/order/save", user, OrderDTO.class);
+ assertEquals("hello world save order", user.getName());
+ // Sleep for jaeger to react
+ Thread.sleep(5000);
+ }
+
+ @Test
+ public void testTraces() throws IOException {
+ String tracesResponse = Objects.requireNonNull(HttpHelper.INSTANCE.getHttpService(JAEGER_HTTP_SERVER, null).body()).string();
+ LOG.info("testTraces get response from jaeger: ({})", tracesResponse);
+ JsonArray array = JsonParser.parseString(tracesResponse)
+ .getAsJsonObject()
+ .getAsJsonArray("data")
+ .get(0)
+ .getAsJsonObject()
+ .getAsJsonArray("spans");
+ List<JaegerSpan> spanList = new ArrayList<>();
+ array.forEach(element -> spanList.add(GSON.fromJson(element, JaegerSpan.class)));
+ spanList.forEach(this::assertSpan);
+ }
+
+ private void assertSpan(final JaegerSpan span) {
+ assertNotNull(span);
+ assertNotNull(span.getTraceID());
+ assertNotNull(span.getSpanID());
+ assertNotNull(span.getOperationName());
+ assertNotNull(span.getReferences());
+ assertNotNull(span.getStartTime());
+ assertNotNull(span.getDuration());
+ span.getTags().forEach(tag -> {
+ if ("component".equals(tag.getKey())) {
+ assertComponentTag(tag);
+ }
+ });
+ }
+
+ private void assertComponentTag(final JaegerSpan.Tag tag) {
+ assertEquals("string", tag.getType());
+ assertEquals("shenyu", tag.getValue());
+ }
+}
diff --git a/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/test/java/org/apache/shenyu/integrated/test/agent/opentelemetry/result/JaegerSpan.java b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/test/java/org/apache/shenyu/integrated/test/agent/opentelemetry/result/JaegerSpan.java
new file mode 100644
index 0000000..4b69754
--- /dev/null
+++ b/shenyu-integrated-test/shenyu-integrated-test-agent/shenyu-integrated-test-agent-tracing/shenyu-integrated-test-agent-tracing-opentelemetry/src/test/java/org/apache/shenyu/integrated/test/agent/opentelemetry/result/JaegerSpan.java
@@ -0,0 +1,148 @@
+/*
+ * 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.shenyu.integrated.test.agent.opentelemetry.result;
+
+import java.util.List;
+
+/**
+ * The type jaeger span.
+ */
+public class JaegerSpan {
+
+ private String traceID;
+
+ private String spanID;
+
+ private String operationName;
+
+ private List<Reference> references;
+
+ private Long startTime;
+
+ private Long duration;
+
+ private List<Tag> tags;
+
+ /**
+ * Get traceID.
+ *
+ * @return traceID
+ */
+ public String getTraceID() {
+ return traceID;
+ }
+
+ /**
+ * Get spanID.
+ *
+ * @return spanID
+ */
+ public String getSpanID() {
+ return spanID;
+ }
+
+ /**
+ * Get operationName.
+ *
+ * @return operationName
+ */
+ public String getOperationName() {
+ return operationName;
+ }
+
+ /**
+ * Get references.
+ *
+ * @return references
+ */
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ /**
+ * Get startTime.
+ *
+ * @return startTime
+ */
+ public Long getStartTime() {
+ return startTime;
+ }
+
+ /**
+ * Get duration.
+ *
+ * @return duration
+ */
+ public Long getDuration() {
+ return duration;
+ }
+
+ /**
+ * Get tags.
+ *
+ * @return tags
+ */
+ public List<Tag> getTags() {
+ return tags;
+ }
+
+ public static class Reference {
+
+ private String refType;
+
+ private String traceID;
+
+ private String spanID;
+ }
+
+ public static class Tag {
+
+ private String key;
+
+ private String type;
+
+ private String value;
+
+ /**
+ * Get key.
+ *
+ * @return key
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Get type.
+ *
+ * @return type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Get value.
+ *
+ * @return value
+ */
+ public String getValue() {
+ return value;
+ }
+ }
+}
diff --git a/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/helper/HttpHelper.java b/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/helper/HttpHelper.java
index 213e0f0..c99d7eb 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/helper/HttpHelper.java
+++ b/shenyu-integrated-test/shenyu-integrated-test-common/src/main/java/org/apache/shenyu/integratedtest/common/helper/HttpHelper.java
@@ -174,12 +174,7 @@ public class HttpHelper {
* @throws IOException IO exception
*/
public <S> S getFromGateway(final String path, final Map<String, Object> headers, final Type type) throws IOException {
- Request.Builder requestBuilder = new Request.Builder().url(GATEWAY_END_POINT + path);
- if (!CollectionUtils.isEmpty(headers)) {
- headers.forEach((key, value) -> requestBuilder.addHeader(key, String.valueOf(value)));
- }
- Request request = requestBuilder.build();
- Response response = client.newCall(request).execute();
+ Response response = getHttpService(GATEWAY_END_POINT + path, headers);
String respBody = Objects.requireNonNull(response.body()).string();
LOG.info("getFromGateway({}) resp({})", path, respBody);
try {
@@ -198,7 +193,19 @@ public class HttpHelper {
* @throws IOException IO exception
*/
public Response getResponseFromGateway(final String path, final Map<String, Object> headers) throws IOException {
- Request.Builder requestBuilder = new Request.Builder().url(GATEWAY_END_POINT + path);
+ return getHttpService(GATEWAY_END_POINT + path, headers);
+ }
+
+ /**
+ * Send a get http request to http service with headers.
+ *
+ * @param url url
+ * @param headers headers
+ * @return response
+ * @throws IOException IO exception
+ */
+ public Response getHttpService(final String url, final Map<String, Object> headers) throws IOException {
+ Request.Builder requestBuilder = new Request.Builder().url(url);
if (!CollectionUtils.isEmpty(headers)) {
headers.forEach((key, value) -> requestBuilder.addHeader(key, String.valueOf(value)));
}