Skip to content

Commit 17b0503

Browse files
authored
optimize: seata-distribution add apm-seata-skywalking (apache#3834)
1 parent 0db08f5 commit 17b0503

File tree

7 files changed

+227
-4
lines changed

7 files changed

+227
-4
lines changed

changes/1.5.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
6363
- [[#3794](https://github.com/seata/seata/pull/3794)] 优化`seata-server`的打包配置,修正Dockerfile的错误配置,并将Dockerfile也打包进去。
6464
- [[#3795](https://github.com/seata/seata/pull/3795)] 优化`zkRegistry`lookup方法性能
6565
- [[#3840](https://github.com/seata/seata/pull/3840)] 优化`apm-skwalking`操作方法生成规则
66-
66+
- [[#3834](https://github.com/seata/seata/pull/3834)] 优化`seata-distribution`增加apm-seata-skywalking包
6767

6868
### test:
6969

changes/en-us/1.5.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
- [[#3738](https://github.com/seata/seata/pull/3738)] `JacksonUndoLogParser` supports to parsing `LocalDateTime`.
6464
- [[#3794](https://github.com/seata/seata/pull/3794)] optimize the packaging of `seata-server`
6565
- [[#3795](https://github.com/seata/seata/pull/3795)] optimize zk registry lookup performance
66-
- [[#3840](https://github.com/seata/seata/pull/3840)] optimization `apm-skwalking` operation method to generate rules
66+
- [[#3840](https://github.com/seata/seata/pull/3840)] optimiza `apm-skwalking` operation method to generate rules
67+
- [[#3834](https://github.com/seata/seata/pull/3834)] optimize `seata-distribution` add `apm-seata-skywalking`
6768

6869

6970
### test:

distribution/bin/seata-server.bat

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ if exist %BASEDIR%/logs (
9191
md "%BASEDIR%/logs"
9292
)
9393

94-
%JAVACMD% %JAVA_OPTS% -server -Xmx2048m -Xms2048m -Xmn1024m -Xss512k -XX:SurvivorRatio=10 -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:MaxDirectMemorySize=1024m -XX:-OmitStackTraceInFastThrow -XX:-UseAdaptiveSizePolicy -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%BASEDIR%"/logs/java_heapdump.hprof -XX:+DisableExplicitGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -Xloggc:"%BASEDIR%"/logs/seata_gc.log -verbose:gc -Dio.netty.leakDetectionLevel=advanced -classpath %CLASSPATH% -Dapp.name="seata-server" -Dapp.repo="%REPO%" -Dapp.home="%BASEDIR%" -Dbasedir="%BASEDIR%" -Dspring.config.location="%BASEDIR%"/conf/application.yml -Dlogging.config="%BASEDIR%"/conf/logback-spring.xml -jar "%BASEDIR%"/target/seata-server.jar %CMD_LINE_ARGS%
94+
if "%SKYWALKING_ENABLE%"=="true" (
95+
set SKYWALKING_OPTS=-javaagent:"%BASEDIR%"/ext/apm-skywalking/skywalking-agent.jar -Dskywalking_config="%BASEDIR%"/ext/apm-skywalking/config/agent.config -Dskywalking.logging.dir="%BASEDIR%"/logs
96+
echo "apm-skywalking enabled opts: %SKYWALKING_OPTS%"
97+
) else (
98+
echo "apm-skywalking not enabled"
99+
)
100+
101+
%JAVACMD% %JAVA_OPTS% %SKYWALKING_OPTS% -server -Xmx2048m -Xms2048m -Xmn1024m -Xss512k -XX:SurvivorRatio=10 -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:MaxDirectMemorySize=1024m -XX:-OmitStackTraceInFastThrow -XX:-UseAdaptiveSizePolicy -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%BASEDIR%"/logs/java_heapdump.hprof -XX:+DisableExplicitGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -Xloggc:"%BASEDIR%"/logs/seata_gc.log -verbose:gc -Dio.netty.leakDetectionLevel=advanced -classpath %CLASSPATH% -Dapp.name="seata-server" -Dapp.repo="%REPO%" -Dapp.home="%BASEDIR%" -Dbasedir="%BASEDIR%" -Dspring.config.location="%BASEDIR%"/conf/application.yml -Dlogging.config="%BASEDIR%"/conf/logback-spring.xml -jar "%BASEDIR%"/target/seata-server.jar %CMD_LINE_ARGS%
95102
if %ERRORLEVEL% NEQ 0 goto error
96103
goto end
97104

distribution/bin/seata-server.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ if $cygwin; then
117117
[ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
118118
fi
119119

120+
if [ "$SKYWALKING_ENABLE" = "true" ]; then
121+
SKYWALKING_OPTS="-javaagent:${BASEDIR}/ext/apm-skywalking/skywalking-agent.jar -Dskywalking_config=${BASEDIR}/ext/apm-skywalking/config/agent.config -Dskywalking.logging.dir=${BASEDIR}/logs"
122+
JAVA_OPT="${JAVA_OPT} $SKYWALKING_OPTS"
123+
echo "apm-skywalking enabled opts: $SKYWALKING_OPTS"
124+
else
125+
echo "apm-skywalking not enabled"
126+
fi
120127
JAVA_OPT="${JAVA_OPT} -server -Xmx2048m -Xms2048m -Xmn1024m -Xss512k -XX:SurvivorRatio=10 -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:MaxDirectMemorySize=1024m -XX:-OmitStackTraceInFastThrow -XX:-UseAdaptiveSizePolicy"
121128
JAVA_OPT="${JAVA_OPT} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BASEDIR}/logs/java_heapdump.hprof -XX:+DisableExplicitGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -Xloggc:${BASEDIR}/logs/seata_gc.log -verbose:gc"
122129
JAVA_OPT="${JAVA_OPT} -Dio.netty.leakDetectionLevel=advanced"

distribution/release-seata.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
<include>**/*.xml</include>
5151
</includes>
5252
</fileSet>
53+
54+
<fileSet>
55+
<directory>../ext/apm-seata-skywalking-plugin/target/ext/skywalking-agent/</directory>
56+
<outputDirectory>ext/apm-skywalking/</outputDirectory>
57+
</fileSet>
5358
</fileSets>
5459

5560
<files>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# The agent namespace
18+
# agent.namespace=${SW_AGENT_NAMESPACE:default-namespace}
19+
20+
# The service name in UI
21+
agent.service_name=${SW_AGENT_NAME:seata_server}
22+
23+
# The number of sampled traces per 3 seconds
24+
# Negative or zero means off, by default
25+
# agent.sample_n_per_3_secs=${SW_AGENT_SAMPLE:-1}
26+
27+
# Authentication active is based on backend setting, see application.yml for more details.
28+
# agent.authentication = ${SW_AGENT_AUTHENTICATION:xxxx}
29+
30+
# The max amount of spans in a single segment.
31+
# Through this config item, SkyWalking keep your application memory cost estimated.
32+
# agent.span_limit_per_segment=${SW_AGENT_SPAN_LIMIT:150}
33+
34+
# If the operation name of the first span is included in this set, this segment should be ignored. Multiple values should be separated by `,`.
35+
# agent.ignore_suffix=${SW_AGENT_IGNORE_SUFFIX:.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg}
36+
37+
# If true, SkyWalking agent will save all instrumented classes files in `/debugging` folder.
38+
# SkyWalking team may ask for these files in order to resolve compatible problem.
39+
# agent.is_open_debugging_class = ${SW_AGENT_OPEN_DEBUG:true}
40+
41+
# If true, SkyWalking agent will cache all instrumented classes files to memory or disk files (decided by class cache mode),
42+
# allow other javaagent to enhance those classes that enhanced by SkyWalking agent.
43+
# agent.is_cache_enhanced_class = ${SW_AGENT_CACHE_CLASS:false}
44+
45+
# The instrumented classes cache mode: MEMORY or FILE
46+
# MEMORY: cache class bytes to memory, if instrumented classes is too many or too large, it may take up more memory
47+
# FILE: cache class bytes in `/class-cache` folder, automatically clean up cached class files when the application exits
48+
# agent.class_cache_mode = ${SW_AGENT_CLASS_CACHE_MODE:MEMORY}
49+
50+
# The operationName max length
51+
# Notice, in the current practice, we don't recommend the length over 190.
52+
# agent.operation_name_threshold=${SW_AGENT_OPERATION_NAME_THRESHOLD:150}
53+
54+
# The agent use gRPC plain text in default.
55+
# If true, SkyWalking agent uses TLS even no CA file detected.
56+
# agent.force_tls=${SW_AGENT_FORCE_TLS:false}
57+
58+
# If true, skywalking agent will enable profile when user create a new profile task. Otherwise disable profile.
59+
# profile.active=${SW_AGENT_PROFILE_ACTIVE:true}
60+
61+
# Parallel monitor segment count
62+
# profile.max_parallel=${SW_AGENT_PROFILE_MAX_PARALLEL:5}
63+
64+
# Max monitor segment time(minutes), if current segment monitor time out of limit, then stop it.
65+
# profile.duration=${SW_AGENT_PROFILE_DURATION:10}
66+
67+
# Max dump thread stack depth
68+
# profile.dump_max_stack_depth=${SW_AGENT_PROFILE_DUMP_MAX_STACK_DEPTH:500}
69+
70+
# Snapshot transport to backend buffer size
71+
# profile.snapshot_transport_buffer_size=${SW_AGENT_PROFILE_SNAPSHOT_TRANSPORT_BUFFER_SIZE:50}
72+
73+
# Backend service addresses.
74+
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:127.0.0.1:11800}
75+
76+
# Logging file_name
77+
logging.file_name=${SW_LOGGING_FILE_NAME:skywalking-api.log}
78+
79+
# Logging level
80+
logging.level=${SW_LOGGING_LEVEL:INFO}
81+
82+
# Logging dir
83+
# logging.dir=${SW_LOGGING_DIR:""}
84+
85+
# Logging max_file_size, default: 300 * 1024 * 1024 = 314572800
86+
# logging.max_file_size=${SW_LOGGING_MAX_FILE_SIZE:314572800}
87+
88+
# The max history log files. When rollover happened, if log files exceed this number,
89+
# then the oldest file will be delete. Negative or zero means off, by default.
90+
# logging.max_history_files=${SW_LOGGING_MAX_HISTORY_FILES:-1}
91+
92+
# Listed exceptions would not be treated as an error. Because in some codes, the exception is being used as a way of controlling business flow.
93+
# Besides, the annotation named IgnoredException in the trace toolkit is another way to configure ignored exceptions.
94+
# statuscheck.ignored_exceptions=${SW_STATUSCHECK_IGNORED_EXCEPTIONS:}
95+
96+
# The max recursive depth when checking the exception traced by the agent. Typically, we don't recommend setting this more than 10, which could cause a performance issue. Negative value and 0 would be ignored, which means all exceptions would make the span tagged in error status.
97+
# statuscheck.max_recursive_depth=${SW_STATUSCHECK_MAX_RECURSIVE_DEPTH:1}
98+
99+
# Mount the specific folders of the plugins. Plugins in mounted folders would work.
100+
plugin.mount=${SW_MOUNT_FOLDERS:plugins,activations}
101+
102+
# Exclude activated plugins
103+
# plugin.exclude_plugins=${SW_EXCLUDE_PLUGINS:}
104+
105+
# If set to true, the parameters of the sql (typically java.sql.PreparedStatement) would be collected.
106+
plugin.jdbc.trace_sql_parameters=${SW_JDBC_TRACE_SQL_PARAMETERS:true}
107+
108+
# Kafka producer configuration
109+
# plugin.kafka.bootstrap_servers=${SW_KAFKA_BOOTSTRAP_SERVERS:localhost:9092}
110+
# if you want to set namespace. please make sure the OAP server has set it in Kafka fetcher module
111+
# plugin.kafka.namespace=${SW_KAFKA_NAMESPACE:""}
112+
113+
# Match spring bean with regex expression for classname
114+
# plugin.springannotation.classname_match_regex=${SW_SPRINGANNOTATION_CLASSNAME_MATCH_REGEX:}
115+
116+
# If set to true, to identify the current node as Seata Server,and Seata server node should not be modify
117+
plugin.seata.server=${SW_SEATA_SERVER:true}

ext/apm-seata-skywalking-plugin/pom.xml

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@
2828
<packaging>jar</packaging>
2929
<name>apm-seata-skywalking-plugin ${project.version}</name>
3030

31+
<properties>
32+
<skywalking.version>8.6.0</skywalking.version>
33+
<agent.dir>${project.build.directory}/ext/skywalking-agent/</agent.dir>
34+
<agent-plugins.dir>${agent.dir}/plugins/</agent-plugins.dir>
35+
<agent-config.dir>${agent.dir}/config</agent-config.dir>
36+
</properties>
37+
38+
3139
<dependencies>
3240
<dependency>
3341
<groupId>org.apache.skywalking</groupId>
3442
<artifactId>apm-agent-core</artifactId>
35-
<version>8.6.0</version>
43+
<version>${skywalking.version}</version>
3644
<scope>provided</scope>
3745
</dependency>
3846
<dependency>
@@ -83,6 +91,84 @@
8391
</execution>
8492
</executions>
8593
</plugin>
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-dependency-plugin</artifactId>
97+
<executions>
98+
<execution>
99+
<id>copy</id>
100+
<phase>package</phase>
101+
<goals>
102+
<goal>copy</goal>
103+
</goals>
104+
<configuration>
105+
<artifactItems>
106+
<artifactItem>
107+
<groupId>org.apache.skywalking</groupId>
108+
<artifactId>apm-agent</artifactId>
109+
<version>${skywalking.version}</version>
110+
<destFileName>skywalking-agent.jar</destFileName>
111+
<outputDirectory>${agent.dir}</outputDirectory>
112+
</artifactItem>
113+
<artifactItem>
114+
<groupId>io.seata</groupId>
115+
<artifactId>apm-seata-skywalking-plugin</artifactId>
116+
<version>${project.version}</version>
117+
<outputDirectory>${agent-plugins.dir}</outputDirectory>
118+
</artifactItem>
119+
<artifactItem>
120+
<groupId>org.apache.skywalking</groupId>
121+
<artifactId>apm-jdbc-commons</artifactId>
122+
<version>${skywalking.version}</version>
123+
<outputDirectory>${agent-plugins.dir}</outputDirectory>
124+
</artifactItem>
125+
<artifactItem>
126+
<groupId>org.apache.skywalking</groupId>
127+
<artifactId>apm-mysql-commons</artifactId>
128+
<version>${skywalking.version}</version>
129+
<outputDirectory>${agent-plugins.dir}</outputDirectory>
130+
</artifactItem>
131+
<artifactItem>
132+
<groupId>org.apache.skywalking</groupId>
133+
<artifactId>apm-mysql-5.x-plugin</artifactId>
134+
<version>${skywalking.version}</version>
135+
<outputDirectory>${agent-plugins.dir}</outputDirectory>
136+
</artifactItem>
137+
<artifactItem>
138+
<groupId>org.apache.skywalking</groupId>
139+
<artifactId>apm-mysql-6.x-plugin</artifactId>
140+
<version>${skywalking.version}</version>
141+
<outputDirectory>${agent-plugins.dir}</outputDirectory>
142+
</artifactItem>
143+
<artifactItem>
144+
<groupId>org.apache.skywalking</groupId>
145+
<artifactId>apm-mysql-8.x-plugin</artifactId>
146+
<version>${skywalking.version}</version>
147+
<outputDirectory>${agent-plugins.dir}</outputDirectory>
148+
</artifactItem>
149+
</artifactItems>
150+
</configuration>
151+
</execution>
152+
</executions>
153+
</plugin>
154+
<plugin>
155+
<groupId>org.apache.maven.plugins</groupId>
156+
<artifactId>maven-antrun-plugin</artifactId>
157+
<version>1.8</version>
158+
<executions>
159+
<execution>
160+
<phase>package</phase>
161+
<goals>
162+
<goal>run</goal>
163+
</goals>
164+
<configuration>
165+
<tasks>
166+
<copy overwrite="true" file="${project.basedir}/config/agent.config" tofile="${agent-config.dir}/agent.config" />
167+
</tasks>
168+
</configuration>
169+
</execution>
170+
</executions>
171+
</plugin>
86172
</plugins>
87173
</build>
88174
</project>

0 commit comments

Comments
 (0)