Skip to content

Commit

Permalink
Merge pull request #56 from yanghaiji/demo
Browse files Browse the repository at this point in the history
add SkywalkingApp  ➕ 🆕
  • Loading branch information
yanghaiji authored Dec 24, 2021
2 parents 696d848 + 064ce20 commit 5bd9088
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
| resttemplate-demo | http调用工具 |
| seata-demo | 分布式事务框架 |
| shardingsphere-demo | 分库分表 |
| Skywalking-demo | Skywalking APM 全链路追踪 |
| spring-event-demo | spring 企业级事件应用 |
| spring-spel-demo | sping SPEL 企业级开发相关 |
| security-demo | security 安全认证实现RBAC |
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<module>security-token-demo</module>
<module>testng-demo</module>
<module>okhttp-demo</module>
<module>skywalking-demo</module>
</modules>

<properties>
Expand Down
22 changes: 22 additions & 0 deletions skywalking-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>advanced-demo</artifactId>
<groupId>com.javayh.advanced</groupId>
<version>1.0.0.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>skywalking-demo</artifactId>

<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-logback-1.x</artifactId>
<version>8.5.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.javayh.skywalking.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* <p>
*
* </p>
*
* @author Dylan
* @version 1.0.0
* @since 2021-12-24
*/
@SpringBootApplication
public class SkywalkingApp {

public static void main(String[] args) {
SpringApplication.run(SkywalkingApp.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.javayh.skywalking.demo;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* <p>
*
* </p>
*
* @author Dylan
* @version 1.0.0
* @since 2021-12-24
*/
@RestController
public class SkywalkingDemoWeb {

@GetMapping
public String getMapping() {
return "SkywalkingApp";
}
}
6 changes: 6 additions & 0 deletions skywalking-demo/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
server:
port: 8090

spring:
application:
name: Skywalking-demo
45 changes: 45 additions & 0 deletions skywalking-demo/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logback</contextName>
<property name="Log_Home" value="logs/javayh"/>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d [%thread] %-5level %logger{36} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!--按天生成日志-->
<appender name="logFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<!-- 过滤器,只打印ERROR级别的日志 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>
${Log_Home}/profile_%d{yyyy-MM-dd}.log
</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>7</MaxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d [%thread] %-5level %logger - %msg%n
</Pattern>
</layout>
</appender>
<appender name="msystem-log" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<!-- 日志输出编码 -->
<encoder>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="logFile"/>
<appender-ref ref="msystem-log"/>
</root>

</configuration>
17 changes: 17 additions & 0 deletions skywalking-demo/src/main/resources/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
# SkyWalking Agent配置
## 需要在启动的脚本里加入如下参数,请将skywalking-agent 的路径指定到自己的安装路径
# skywalking-agent 的具体位置
#-javaagent:./apache-skywalking-apm-bin/agent/skywalking-agent.jar
# 服务名称
#-Dskywalking.agent.service_name=${you service_name}
# 采集的后端地址 当机器不在一个服务上时需要指定
#-Dskywalking.collector.backend_service=127.0.0.1:11800
export SW_AGENT_NAME=skywalking-demo #Agent名字,一般使用`spring.application.name`
export SW_AGENT_COLLECTOR_BACKEND_SERVICES=192.168.1.180:11800 #配置 Collector 地址。
export SW_AGENT_SPAN_LIMIT=2000 #配置链路的最大Span数量,默认为 300。
export JAVA_AGENT=-javaagent:/opt/module/skywalking-apm-bin-es7/agent/skywalking-agent.jar
java $JAVA_AGENT -jar /opt/module/demo/user-center-0.0.1-SNAPSHOT.jar #jar启动



0 comments on commit 5bd9088

Please sign in to comment.