Skip to content

mgwn/skywalking-demo

Repository files navigation

Skywalking demo

https://github.com/apache/skywalking/blob/master/docs/en/setup/service-agent/java-agent/Supported-list.md

Requirement

  • JDK 1.8+
  • Gradle 5+
  • Docker(with docker-compose)

Run Middleware in docker

docker-compose

Download java agent

  • http://skywalking.apache.org/downloads/
    tar xzf apache-skywalking-apm-6.2.0.tar.gz 
    mv -f apache-skywalking-apm-bin/agent ./agent
    rm -rf apache-skywalking-apm-bin
  • Add manually trace in code
    • gradle
     implementation 'org.apache.skywalking:apm-toolkit-trace:6.2.0'
    • Code: @Trace, @TraceCrossThread, ActiveSpan, TraceContext
  • Add logback trace id
    • gradle
     implementation 'org.apache.skywalking:apm-toolkit-logback-1.x:6.2.0'
    • logback.xml
     <conversionRule conversionWord="tid" converterClass="org.apache.skywalking.apm.toolkit.log.logback.v1.x.LogbackPatternConverter"/>
     <property name="CONSOLE_LOG_PATTERN"
               value="%clr([%tid]%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
    
  • [Not Recommend]Enable spring annotation trace plugin
     mv agent/optional-plugins/apm-spring-annotation-plugin-6.2.0.jar agent/plugins/

Enable agent

For gradle as an example

bootRun {
	jvmArgs = ["-Dskywalking.agent.service_name=gateway", "-javaagent:$projectDir/agent/skywalking-agent.jar"]
}
  • skywalking.agent.service_name should be same as service name in application.yml to avoid some issues.

Run services

gradle :gateway:bootRun
gradle :demo-service:bootRun

Test with postman

import Demo.postman_collection.json into postman

About

A demo for skywalking with spring boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages