# 背景

  1. 如何串联整个调用链路,快速定位问题

  2. 如何理清各个微服务之间的依赖关系

  3. 如何进行各个微服务接口的性能分析

# 简介

skywalking是一个优秀的 国产 开源 分布式链路追踪 框架,2015年由个人吴晟(华为开发者)开源 , 2017年加入Apache孵化器。短短两年就被Apache收入麾下,实力可见一斑。

skywalking支持dubbo,SpringCloud,SpringBoot集成,代码无侵入,通信方式采用GRPC,性能较好,实现方式是java探针,支持告警,支持JVM监控,支持全局调用统计等等,功能较完善。

# 架构

# 服务搭建

SkyWalking is an Observability Analysis Platform and Application Performance Management system.

OAP:可观测性分析平台

APM:应用性能管理平台

# tar包安装

-----
    |
    |----agent                          探针,客户端需要指定的目录,包含一个jar,负责信息的收集
          |--activations
          |--bootstrap-plugins
          |--config                     skywalking agent配置
          |--logs                       skywalking agent日志
          |--optional-plugins           可选插件
          |--optional-reporter-plugins  
          |--plugins                    插件
          |--skywalking-agent.jar       探针jar
    |----bin                            服务启动的相关命令
          |--oapService.bat             启动oap服务  
          |--oapServiceInit.bat  
          |--oapServiceInit.sh  
          |--oapServiceNoInit.bat  
          |--oapServiceNoInit.sh  
          |--oapService.sh  
          |--startup.bat                同时启动oap和ui服务  
          |--startup.sh  
          |--webappService.bat          启动UI服务  
          |--webappService.sh  
    |----config                         配置文件相关
          |--application.yml            oap服务相关配置【主配置】  
          |--gateways.yml  
          |--....  
    |----config-examples
    |----licenses
    |----oap-libs                       oap所需依赖
    |----tools
    |----webapp                         UI服务相关
          |--skywalking-webapp.jar  
          |--webapp.yml                 UI相关配置  
    |----LICENSE
    |----NOTICE
    |----README.txt

# oap配置

oap的配置相当简单,因为文件中已经给了默认值,因此按需配置即可。

如,将skywalking注册到nacos;使用h2或mysql进行存储。

cluster:
  selector: ${SW_CLUSTER:standalone}
  standalone:
  # Please check your ZooKeeper is 3.5+, However, it is also compatible with ZooKeeper 3.4.x. Replace the ZooKeeper 3.5+
  # library the oap-libs folder with your ZooKeeper 3.4.x library.
  zookeeper:
    nameSpace: ${SW_NAMESPACE:""}
    hostPort: ${SW_CLUSTER_ZK_HOST_PORT:localhost:2181}
    # Retry Policy
    baseSleepTimeMs: ${SW_CLUSTER_ZK_SLEEP_TIME:1000} # initial amount of time to wait between retries
    maxRetries: ${SW_CLUSTER_ZK_MAX_RETRIES:3} # max number of times to retry
    # Enable ACL
    enableACL: ${SW_ZK_ENABLE_ACL:false} # disable ACL in default
    schema: ${SW_ZK_SCHEMA:digest} # only support digest schema
    expression: ${SW_ZK_EXPRESSION:skywalking:skywalking}
  kubernetes:
    namespace: ${SW_CLUSTER_K8S_NAMESPACE:default}
    labelSelector: ${SW_CLUSTER_K8S_LABEL:app=collector,release=skywalking}
    uidEnvName: ${SW_CLUSTER_K8S_UID:SKYWALKING_COLLECTOR_UID}
  consul:
    serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
    # Consul cluster nodes, example: 10.0.0.1:8500,10.0.0.2:8500,10.0.0.3:8500
    hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500}
    aclToken: ${SW_CLUSTER_CONSUL_ACLTOKEN:""}
  etcd:
    # etcd cluster nodes, example: 10.0.0.1:2379,10.0.0.2:2379,10.0.0.3:2379
    endpoints: ${SW_CLUSTER_ETCD_ENDPOINTS:localhost:2379}
    namespace: ${SW_CLUSTER_ETCD_NAMESPACE:/skywalking}
    serviceName: ${SW_SCLUSTER_ETCD_ERVICE_NAME:"SkyWalking_OAP_Cluster"}
    authentication: ${SW_CLUSTER_ETCD_AUTHENTICATION:false}
    user: ${SW_SCLUSTER_ETCD_USER:}
    password: ${SW_SCLUSTER_ETCD_PASSWORD:}
  nacos:
    serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"}
    hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848}
    # Nacos Configuration namespace
    namespace: ${SW_CLUSTER_NACOS_NAMESPACE:"public"}
    # Nacos auth username
    username: ${SW_CLUSTER_NACOS_USERNAME:""}
    password: ${SW_CLUSTER_NACOS_PASSWORD:""}
    # Nacos auth accessKey
    accessKey: ${SW_CLUSTER_NACOS_ACCESSKEY:""}
    secretKey: ${SW_CLUSTER_NACOS_SECRETKEY:""}


storage:
  selector: ${SW_STORAGE:h2}
  h2:
    driver: ${SW_STORAGE_H2_DRIVER:org.h2.jdbcx.JdbcDataSource}
    url: ${SW_STORAGE_H2_URL:jdbc:h2:mem:skywalking-oap-db;DB_CLOSE_DELAY=-1}
    user: ${SW_STORAGE_H2_USER:sa}
    metadataQueryMaxSize: ${SW_STORAGE_H2_QUERY_MAX_SIZE:5000}
    maxSizeOfArrayColumn: ${SW_STORAGE_MAX_SIZE_OF_ARRAY_COLUMN:20}
    numOfSearchableValuesPerTag: ${SW_STORAGE_NUM_OF_SEARCHABLE_VALUES_PER_TAG:2}
  mysql:
    properties:
      jdbcUrl: ${SW_JDBC_URL:"jdbc:mysql://localhost:3306/swtest"}
      dataSource.user: ${SW_DATA_SOURCE_USER:root}
      dataSource.password: ${SW_DATA_SOURCE_PASSWORD:root@1234}
      dataSource.cachePrepStmts: ${SW_DATA_SOURCE_CACHE_PREP_STMTS:true}
      dataSource.prepStmtCacheSize: ${SW_DATA_SOURCE_PREP_STMT_CACHE_SQL_SIZE:250}
      dataSource.prepStmtCacheSqlLimit: ${SW_DATA_SOURCE_PREP_STMT_CACHE_SQL_LIMIT:2048}
      dataSource.useServerPrepStmts: ${SW_DATA_SOURCE_USE_SERVER_PREP_STMTS:true}
    metadataQueryMaxSize: ${SW_STORAGE_MYSQL_QUERY_MAX_SIZE:5000}
    maxSizeOfArrayColumn: ${SW_STORAGE_MAX_SIZE_OF_ARRAY_COLUMN:20}
    numOfSearchableValuesPerTag: ${SW_STORAGE_NUM_OF_SEARCHABLE_VALUES_PER_TAG:2}

# UI配置

通常,只需要修改server.port即可,这里修改为8888

server:
  port: 8888

spring:
  cloud:
    gateway:
      routes:
        - id: oap-route
          uri: lb://oap-service
          predicates:
            - Path=/graphql/**
    discovery:
      client:
        simple:
          instances:
            oap-service:
              - uri: http://127.0.0.1:12800
            # - uri: http://<oap-host-1>:<oap-port1>
            # - uri: http://<oap-host-2>:<oap-port2>

  mvc:
    throw-exception-if-no-handler-found: true

  web:
    resources:
      add-mappings: true

management:
  server:
    base-path: /manage

# Docker安装

注意:

  1. 要先把数据卷中两个目录的内容,在宿主机上准备好
    • 先使用h2启动一次,把数据复制出来 docker cp skywalking_oap:/skywalking/oap-libs .
    • 在./data/oap-libs中新增 mysql-connector-java-8.0.19.jar的jar包 wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.19/mysql-connector-java-8.0.19.jar
    • 使用数据卷
    • 再使用mysql重新启动
  2. 把mysql的数据库信息修改了
  3. ui的SW_OAP_ADDRESS在不同的版本需要有不同的取值 (opens new window)

oap镜像 (opens new window)

ui镜像 (opens new window)

version: '3.3'
services:
  oap:
    image: apache/skywalking-oap-server:8.7.0-es7
    container_name: skywalking_oap
    restart: always
    ports:
      - 11800:11800
      - 12800:12800
    environment:
      TZ: Asia/Shanghai
      SW_CLUSTER: nacos
      SW_CLUSTER_NACOS_HOST_PORT: 192.168.3.110:30848
      SW_STORAGE: mysql
      SW_JDBC_URL: jdbc:mysql://47.104.79.114:3306/skywalking?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false
      SW_DATA_SOURCE_USER: root
      SW_DATA_SOURCE_PASSWORD: xxx
      
    # 数据卷按需 解除注释
    volumes:
       - ./data/oap-libs:/skywalking/oap-libs

  ui:
    image: apache/skywalking-ui:8.7.0
    container_name: skywalking_ui
    depends_on:
      - oap
    links:
      - oap
    restart: always
    ports:
      - 8000:8080
    environment:
      # 注意SW_OAP_ADDRESS: 8.7.0          是 http://oap:12800  
      # 注意SW_OAP_ADDRESS: 其他版本如8.6.0 是 oap:12800  
      SW_OAP_ADDRESS: http://oap:12800
      TZ: Asia/Shanghai

# 探针植入

# IDEA

  1. 将sw_home/agent目录下的内容拷贝到指定位置(通常与微服务平级)
  2. 添jvm参数如下
-javaagent:/home/hellofun/IdeaProjects/qcsd/skywalking-agent/skywalking-agent.jar
-Dskywalking.agent.service_name=your.spring.application.name
-Dskywalking.collector.backend_service:127.0.0.1:11800

可以看到,在启动项目的时候,首先会打印如下日志:

DEBUG 2022-03-22 10:17:12:057 main AgentPackagePath : The beacon class location is jar:file:/home/hellofun/IdeaProjects/qcsd/skywalking-agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class. 
INFO 2022-03-22 10:17:12:059 main SnifferConfigInitializer : Config file found in /home/hellofun/IdeaProjects/qcsd/skywalking-agent/config/agent.config. 

# agent归档

插件介绍 (opens new window)

Maven的Assembly插件,提供把一个工程依赖元素、模块、网站文档等其他文件存放到单个归档文件里。支持的归档文件类型有:

  1. zip
  2. tar.gz
  3. tar.bz2
  4. jar
  5. war

可以在Dockerfile文件中,使用ADD命令将agent归档文件引入镜像中

此处以将SkyWalking探针打包为tar.gz为例,为构建Docker镜像做好准备。

通常,将agent归档之后,可以放在一个nginx/tomcat主机中进行托管,统一维护,后续使用的话使用wget命令进行拉取

防止打包后的tar包过于分散,导致重复操作

# pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>fun.hellofun</groupId>
    <artifactId>skywalking-agent-assembly</artifactId>
    <version>1</version>

    <name>skywalking-agent-assembly</name>
    <description>SkyWalking归档</description>
    <url>http://hellofun.fun</url>

    <properties>
        <skywalking.version>8.7.0</skywalking.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <finalName>${project.artifactId}-${skywalking.version}</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <!--                                配置描述文件路径-->
                        <descriptor>src/main/resources/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <!--                    配置执行器-->
                    <execution>
                        <id>make-assembly</id>
                        <!--                        绑定到package生命周期阶段上-->
                        <phase>package</phase>
                        <goals>
                            <!--                            只运行一次-->
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

# assembly.xml

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 ">

    <!-- id 标识符,添加到生成文件名称的后缀符。如果指定 id 的话(这里指定的是项目的版本),目标文件则是 ${artifactId}-${id}.jar。【如terminal-dispatch-5.0.0.0.jar】 -->
    <id>id</id>

    <formats>
        <!--        打包的文件格式,支持zip/tar.gz/tar.bz2/jar/dir/war-->
        <format>tar.gz</format>
    </formats>

    <!--    tar.gz压缩包下是否生成和项目名相同的根目录,有需要请设置成true-->
    <includeBaseDirectory>true</includeBaseDirectory>

    <fileSets>
        <fileSet>
            <!--            设置需要打包的文件路径-->
            <directory>agent</directory>
            <!--            打包后的输出路径-->
            <outputDirectory></outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

# 文件结构

--other-micro-service
--skywalking-agent-assembly
       |
       |--agent
             |  
             |--activations  
             |--config  
             |--logs  
             |--...
             |--skywalking-agent.jar
       |--src
            |
            |--main
                |
                |--resources
                       |
                       |--assembly.xml
       |--target(自动生成)
       |--pom.xml

# 数据持久化

只要服务端重启,链路追踪的数据将会丢失。因为SkyWalking默认使用了基于内存存储的H2数据库。

根据实际情况,可以选择MySQL(小项目)或ElasticSearch(企业、大项目)进行存储。

# MYSQL

  1. 修改sw_home/config/application.yml
  2. 添加MySQL的jdbc依赖到sw_home/oap-libs目录下
    • Because you need to add manually. MySQL driver is GPL licensed, it is not allowed to include in Apache release.
  3. 在mysql中新建skywalking数据库,字符集为latin1
  4. skywalking会在数据库中自动创建表
cd apache-skywalking-apm-bin-es7/oap-libs/ 
wget http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.48/mysql-connector-java-5.1.48.jar
storage:
  selector: ${SW_STORAGE:mysql}
  mysql:
    properties:
      jdbcUrl: ${SW_JDBC_URL:"jdbc:mysql://47.104.79.114:3306/skywalking?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false"}
      dataSource.user: ${SW_DATA_SOURCE_USER:root}
      dataSource.password: ${SW_DATA_SOURCE_PASSWORD:xxx}
      dataSource.cachePrepStmts: ${SW_DATA_SOURCE_CACHE_PREP_STMTS:true}
      dataSource.prepStmtCacheSize: ${SW_DATA_SOURCE_PREP_STMT_CACHE_SQL_SIZE:250}
      dataSource.prepStmtCacheSqlLimit: ${SW_DATA_SOURCE_PREP_STMT_CACHE_SQL_LIMIT:2048}
      dataSource.useServerPrepStmts: ${SW_DATA_SOURCE_USE_SERVER_PREP_STMTS:true}
    metadataQueryMaxSize: ${SW_STORAGE_MYSQL_QUERY_MAX_SIZE:5000}
    maxSizeOfArrayColumn: ${SW_STORAGE_MAX_SIZE_OF_ARRAY_COLUMN:20}
    numOfSearchableValuesPerTag: ${SW_STORAGE_NUM_OF_SEARCHABLE_VALUES_PER_TAG:2}

SkyWalking在数据库中自动创建了如下的表

# ElasticSearch

待补充

# 日志监控

在SkyWalking的UI端有一个日志模块,用于收集客户端的日志,默认是没有数据的。

官方文档提供了如下的配置步骤 (opens new window)

# 添加依赖

<dependency>
    <groupId>org.apache.skywalking</groupId>
    <artifactId>apm-toolkit-logback-1.x</artifactId>
    <version>{project.release.version}</version>
</dependency>

# 日志配置

在项目的resources目录下新建logback-spring.xml文件,写入以下内容:

<configuration scan="true" scanPeriod=" 5 seconds">

    <!--    控制台打印traceId的格式,只需要加一个 %tid-->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
            <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc.TraceIdMDCPatternLogbackLayout">
                <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{tid}] [%thread] %-5level %logger{36} -%msg%n</Pattern>
            </layout>
        </encoder>
    </appender>

    <!--   异步打印-->
    <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
        <discardingThreshold>0</discardingThreshold>
        <queueSize>1024</queueSize>
        <neverBlock>true</neverBlock>
        <appender-ref ref="STDOUT"/>
    </appender>

    <!--   日志传输到skywalking中的appender,通过grpc传输-->
    <appender name="grpc-log" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
            <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc.TraceIdMDCPatternLogbackLayout">
                <Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{tid}] [%thread] %-5level %logger{36} -%msg%n</Pattern>
            </layout>
        </encoder>
    </appender>

    <!--   日志级别为INFO,控制台打印,并且传输到skywalking-->
    <root level="INFO">
        <appender-ref ref="ASYNC"/>
        <appender-ref ref="grpc-log"/>
    </root>
</configuration>

# 效果

# IDEA控制台

可以看到已经打印出了traceId

2022-03-22 13:18:50.020 [TID:N/A] [main] INFO  c.q.u.service.UserServiceApplication -Started UserServiceApplication in 9.15 seconds (JVM running for 15.89)
2022-03-22 13:19:09.446 [TID:028edea51ee3446baf789c991db65aa2.374.16479263494300001] [http-nio-9104-exec-1] INFO  o.a.c.c.C.[Tomcat].[localhost].[/] -Initializing Spring DispatcherServlet 'dispatcherServlet'

# UI

# agent与oap分离

如果agent和oap服务在不同的服务器上,需要在skywalking-agent/config/agent.config文件中追加如下内容:

plugin.toolkit.log.grpc.reporter.server_host=${SW_GRPC_LOG_SERVER_HOST:10.10.10.1}
plugin.toolkit.log.grpc.reporter.server_port=${SW_GRPC_LOG_SERVER_PORT:11800}
plugin.toolkit.log.grpc.reporter.max_message_size=${SW_GRPC_LOG_MAX_MESSAGE:10485760}
plugin.toolkit.log.grpc.reporter.upstream_timeout=${SW_GRPC_LOG_UPSTREAM_TIMEOUT:30}

# 方法级Trace分析

# 添加依赖

<!--SkyWalking工具类 跟使用的SkyWalking的版本保持一致-->
<dependency>
   <groupId>org.apache.skywalking</groupId>
   <artifactId>apm-toolkit-trace</artifactId>
   <version>8.7.0</version>
</dependency>

# 注解埋点

@Trace
 @Tags({
         @Tag(key = "userId", value = "arg[0]"),
         @Tag(key = "account", value = "arg[1]"),
         @Tag(key = "qcCode", value = "arg[2]"),
         // idNo zodiac等是AccountInfo类中的属性
         @Tag(key = "idNo", value = "returnedObj.idNo"),
         @Tag(key = "zodiac", value = "returnedObj.zodiac")
 })
 @Internal
 @GetMapping("/info/get2")
 public AccountInfo getInfo2(String userId, String account, String qcCode) {
     return accountService.getInfo(userId, account, qcCode);
 }

# 查看结果

# 性能分析

提供对某个接口的性能剖析,提供到基于堆栈的分析结果,方便快速定位问题。

# 监控告警

对于服务的异常,如接口的较长延迟,skywalking会做出告警功能。

# 告警规则

skywalking中的告警规则在sw_home/config/alarm-settings.yml文件中配置,默认如下:

  1. 最近3分钟内服务的平均响应时间超过1秒
  2. 最近2分钟服务成功率低于80%
  3. 最近3分钟90%服务响应时间超过1秒
  4. 最近2分钟内服务实例的平均响应时间超过1s

# 告警回调

当触发了告警规则,skywalking将会调用配置的webhook,开发人员可以进行后续的处理,如发送邮件、微信、钉钉通知运维人员处理。

webhooks:
#  - http://127.0.0.1/notify/
#  - http://127.0.0.1/go-wechat/

webhook指定的接口要符合一定得规则:

  1. POST请求
  2. application/json接收数据
  3. 接收的参数必须是AlarmMessage中指定的参数

其中AlarmMessage这个类随着skywalking版本的迭代可能出现不同,要到对应版本的源码 (opens new window) 中去找到这个类,拷贝中的属性

# 问题

# 链路追踪不显示gateway

拷贝agent/optional-plugins目录下的gateway插件到agent/plugins目录下,然后重启skywalking服务。

# devops目录

--micro-service-A
--micro-service-B
        |
        ----doc         相关文档
        ----B-api
        ----B-service
                |
                --devops
                      |--.env
                      |--boot.sh
                      |--docker-compose.yml
                      |--Dockerfile
                      |--git_push.sh
                --pom.xml
                --src
                   |
                   --main 
                   --test 
                --target

# .env

# 该文件存在的意义,是减少需要修改的文件数量

# 容器名称
# 由于 Docker 容器名称必须是唯一的,因此如果您指定了自定义名称,则不能将服务扩展到 1 个以上的容器。尝试这样做会导致错误。
container_name=wangdiantong

# 镜像名称
image_name=wangdiantong

# 项目名称
project_name=wangdiantong

# 服务端口
server_port=9109

# 端口映射
port_mapping="9109:9109"

# spring环境
spring_profiles_active=dev

# build.sh

#! /bin/sh
# Please note that you must run chomd +x
# ======================================================
# 1. image_name由执行脚本时传递过来
# 2. 注意服务器要定义ALIYUN_DOCKER_IMAGE_USER和ALIYUN_DOCKER_IMAGE_PASSWORD
# ======================================================
#image_name=$1
image_name=wangdiantong
ALIYUN_DOCKER_IMAGE_USER=aaa
ALIYUN_DOCKER_IMAGE_PASSWORD=bbb

# 下载skywalking探针
rm -rf skywalking-agent-assembly-8.7.0.tar.gz
wget http://192.168.3.110:30080/devops/skywalking-agent-assembly-8.7.0.tar.gz

#docker-compose down
docker build -t ${image_name} .
docker login registry.cn-qingdao.aliyuncs.com/qcsd -u ${ALIYUN_DOCKER_IMAGE_USER} -p ${ALIYUN_DOCKER_IMAGE_PASSWORD}
docker tag ${image_name} registry.cn-qingdao.aliyuncs.com/qcsd/${image_name}
docker push registry.cn-qingdao.aliyuncs.com/qcsd/${image_name}
# kubectl delete -f ../${image_name}.yml
# kubectl apply -f ../${image_name}.yml
#docker-compose up -d
#docker-compose logs -f
exit 0

# docker-compose.yml

version: "3"
services:
  base:
    # 指定容器名称
    container_name: wangdiantong
    # 重启机制
    restart: always
    # 镜像
    image: 192.168.3.250:8080/wangdiantong/wangdiantong
    # 访问端口 如果使用 gateway 可以 不关心端口的分配
    #    ports:
    #      - "9101:9101"
    networks:
      - custom_net
    environment:
      # 指定时区
      - TZ=Asia/Shanghai
    volumes:
      - ../logs:/logs
    entrypoint: java -Xms128m -Xmx256m -javaagent:/skywalking-agent-assembly-8.7.0/skywalking-agent.jar -Dskywalking.agent-service_name=wangdiantong -Dspring.profiles.active=dev  -Dproject.name=wangdiantong -jar /app.jar &


networks:
  custom_net:
    external:
      name: app_net

# Dockerfile

FROM openjdk:8u232-jre

# 加入SkyWalking探针
COPY skywalking-agent-assembly-8.7.0.tar.gz /skywalking-agent-assembly-8.7.0.tar.gz
RUN tar -zxvf /skywalking-agent-assembly-8.7.0.tar.gz
ADD wangdiantong.jar /app.jar

# git_push.sh

#!/usr/bin/env bash
echo 'exec>>> [git push]'
echo '...'
echo '...'

# https://blog.csdn.net/ABCisCOOL/article/details/109288845
# read  -p "请输入提交信息Message: " message
# git add .
# git commit -a -m "$message"
git push

#curl http://192.168.3.130:8080/job/wangdiantong/build?token=TOKEN_NAME
curl http://192.168.3.130:8080/job/wangdiantong/build?token=wangdiantong

# 参考

官网 (opens new window)

OpenTracing官方标准 (opens new window)

不懂什么是Skywalking?看这吧! (opens new window)

链路追踪自从用了SkyWalking,睡得真香 (opens new window)

链路追踪:SkyWalking (opens new window)

方法级Trace实现 (opens new window)

使用docker-compose搭建SkyWalking环境 (opens new window)

SkyWalking搭建Nacos注册中心及MySql存储的集群架构 (opens new window)

maven-assembly-plugin指定输出文件名 (opens new window)

Last Updated: 18 days ago