wu-sheng closed pull request #1067: add doc for TraceCrossThread URL: https://github.com/apache/incubator-skywalking/pull/1067
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/docs/README.md b/docs/README.md index 05001275e..7996d3245 100644 --- a/docs/README.md +++ b/docs/README.md @@ -21,6 +21,7 @@ * [log4j2](en/Application-toolkit-log4j-2.x.md) * [logback](en/Application-toolkit-logback-1.x.md) * [Trace](en/Application-toolkit-trace.md) + * [Propagate Context across Thread](en/Application-toolkit-trace-cross-thread.md) * Testing * [Plugin Test](https://github.com/SkywalkingTest/agent-integration-test-report) * [Java Agent Performance Test](https://skywalkingtest.github.io/Agent-Benchmarks/) diff --git a/docs/README_ZH.md b/docs/README_ZH.md index f8c09690c..52522cbdb 100644 --- a/docs/README_ZH.md +++ b/docs/README_ZH.md @@ -21,6 +21,7 @@ * [log4j2组件](cn/Application-toolkit-log4j-2.x-CN.md) * [logback组件](cn/Application-toolkit-logback-1.x-CN.md) * [Trace](cn/Application-toolkit-trace-CN.md) + * [调用链跨线程传递](cn/Application-toolkit-trace-cross-thread-CN.md) * 测试用例 * [插件测试](https://github.com/SkywalkingTest/agent-integration-test-report) * [Java 探针性能测试](https://skywalkingtest.github.io/Agent-Benchmarks/README_zh.html) @@ -38,4 +39,4 @@ * FAQ * [Trace查询有数据,但是没有拓扑图和JVM数据?](cn/FAQ/Why-have-traces-no-others-CN.md) * [加载探针,Console被GRPC日志刷屏](cn/FAQ/Too-many-gRPC-logs-CN.md) - * [Kafka消息消费端链路断裂](cn/FAQ/Kafka-plugin-CN.md) \ No newline at end of file + * [Kafka消息消费端链路断裂](cn/FAQ/Kafka-plugin-CN.md) diff --git a/docs/cn/Application-toolkit-trace-cross-thread-CN.md b/docs/cn/Application-toolkit-trace-cross-thread-CN.md new file mode 100644 index 000000000..513c3d82b --- /dev/null +++ b/docs/cn/Application-toolkit-trace-cross-thread-CN.md @@ -0,0 +1,38 @@ +# 跨线程追踪 +* 使用 maven 和 gradle 依赖相应的工具包 +```xml + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>apm-toolkit-trace</artifactId> + <version>${skywalking.version}</version> + </dependency> +``` + +* 使用方式一. +```java + @TraceCrossThread + public static class MyCallable<String> implements Callable<String> { + @Override + public String call() throws Exception { + return null; + } + } +... + ExecutorService executorService = Executors.newFixedThreadPool(1); + executorService.submit(new MyCallable()); +``` +* 使用方式二. +```java + ExecutorService executorService = Executors.newFixedThreadPool(1); + executorService.submit(CallableWrapper.of(new Callable<String>() { + @Override public String call() throws Exception { + return null; + } + })); +``` +_示例代码,仅供参考_ + + + + + diff --git a/docs/en/Application-toolkit-trace-cross-thread.md b/docs/en/Application-toolkit-trace-cross-thread.md new file mode 100644 index 000000000..308cb83c9 --- /dev/null +++ b/docs/en/Application-toolkit-trace-cross-thread.md @@ -0,0 +1,36 @@ +# trace cross thread +* Dependency the toolkit, such as using maven or gradle +```xml + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>apm-toolkit-trace</artifactId> + <version>${skywalking.version}</version> + </dependency> +``` + +* usage 1. +```java + @TraceCrossThread + public static class MyCallable<String> implements Callable<String> { + @Override + public String call() throws Exception { + return null; + } + } +... + ExecutorService executorService = Executors.newFixedThreadPool(1); + executorService.submit(new MyCallable()); +``` +* usage 2. +```java + ExecutorService executorService = Executors.newFixedThreadPool(1); + executorService.submit(CallableWrapper.of(new Callable<String>() { + @Override public String call() throws Exception { + return null; + } + })); +``` +_Sample codes only_ + + + ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services