[英]scala futures - keeping track of request context when threadId is irrelevant
making first steps using Scala promises/futures in a web server (still Jetty/synchronous for now :( ), as expected the threadId is no longer useful for tracking what happened during a single HTTP request processing. 在Web服务器(目前仍为Jetty / synchronous ::)中使用Scala Promise / futures进行第一步,正如预期的那样,threadId不再对跟踪单个HTTP请求处理期间发生的情况有用。
I guess logging a request token will do the trick - is this the recommended approach? 我想记录请求令牌将解决问题-这是推荐的方法吗? if so can you refer me to some code already doing that?
如果可以的话,您可以让我参考已经做过的一些代码吗?
在这种情况下,我的方法是让一个案例类保存上下文数据(例如请求ID),并将其作为implicit
参数传递给应用程序的所有层。
请原谅我添加了一个答案,但我只是在scala时间( http://scalatimes.com/ )上看到了这一相关想法: http : //www.schibsted.pl/blog/tracing-back-scala-future-chains /要点-用TraceableFuture包装Future,其中添加了“未来堆栈”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.