spring-boot - 为 ForkJoinPool.commonPool() 打开跟踪工具
问题描述
我的应用程序广泛使用CompletableFuture.supplyAsync(() -> someService(context, args));
& 我们依靠 supplyAsync 使用ForkJoinPool.commonPool()
线程池来让服务在自己的线程中运行。
有没有办法在开放跟踪中检测 someService 调用而不将自定义Executor
作为参数传递给 supplyAsync() ?我正在使用 spring 和 jaeger 并具有以下依赖项
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
<version>3.2.2</version>
</dependency>
解决方案
据我所知, 的设计ForkJoinPool.commonPool()
使得不可能以编程方式用检测版本实际替换该池。所以唯一的解决方法是通过字节码操作来做到这一点。
OpenTelemetry Java Automatic Instrumentation库执行了很多魔法,能够通过异步/并发原语正确地传播上下文,您可能想尝试一下。
推荐阅读
- c++ - 海合会
过滤视图不能用无限范围 iota() 编译 - html - Foreach 中的 HTML 部分视图
- json - 是否可以使用 serde_json 反序列化看起来像 JSON(但不是)的数据?
- unity3d - 消除 lerps 之间的延迟
- neural-network - NN可以通过速度而不是求解泊松方程来预测压力吗?
- xslt - 如何仅在 XPATH 中选择相同节点的位置?
- regex - Powershell:如果命令的输出与预期的 3 个字符串的数组不同,则发送电子邮件
- c# - 如何对 IEnumerable 上的一个或多个键进行排序
> 结果集? - go - 在 go-graphql 中获取变量 \"$address\" 不能是非输入类型 \"String!\
- mysql - MySQL JSON - 如何在匹配路径的所有元素上使用 JSON_SET?