Skip to content

Commit

Permalink
增加 skywalking 示例 - opentracing
Browse files Browse the repository at this point in the history
  • Loading branch information
YunaiV committed Jan 5, 2020
1 parent f7548e2 commit c7aa85d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lab-39/lab-39-opentracing/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>lab-39-opentracing</artifactId>

<dependencies>
<!-- SkyWalking Opentracing 集成 -->
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-toolkit-opentracing</artifactId>
<version>6.6.0</version>
</dependency>

<!-- 实现对 SpringMVC 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cn.iocoder.springboot.lab39.skywalkingdemo;

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

@SpringBootApplication
public class OpentracingApplication {

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cn.iocoder.springboot.lab39.skywalkingdemo.controller;

import io.opentracing.Tracer;
import org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo")
public class DemoController {

@GetMapping("/opentracing")
public String echo() {
// 创建一个 Span
Tracer tracer = new SkywalkingTracer();
tracer.buildSpan("custom_operation").withTag("mp", "芋道源码").startManual().finish();

// 返回
return "opentracing";
}

}
2 changes: 2 additions & 0 deletions lab-39/lab-39-opentracing/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server:
port: 8079
1 change: 1 addition & 0 deletions lab-39/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<module>lab-39-activemq</module>
<module>lab-39-logback</module>
<module>lab-39-trace-annotations</module>
<module>lab-39-opentracing</module>
</modules>

</project>

0 comments on commit c7aa85d

Please sign in to comment.