如何将StackDriver跟踪链接到该事件的App Engine日志? [英] How can I link a StackDriver trace to the App Engine log for that event?

查看:146
本文介绍了如何将StackDriver跟踪链接到该事件的App Engine日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我查看AppEngine自动生成的StackDriver跟踪信息时,会出现一个日志链接(它永远不会出现超过一行的日志,但希望它们正在修复它)。

b
$ b

有没有办法告诉StackDriver,当我发送一个跟踪和一组跨度时,request_id将跟踪关联起来?

解决方案

因为您正在搜索某个特定请求的日志,所以它应该只有一个日志。点击左侧三角将展开日志。

如果您不需要转到日志查看器查看日志,则可以使用跟踪详细信息页面上的显示日志按钮。通过点击它,它会将log语句嵌入到跨度之间。日志语句的位置由日志时间决定,相对于跨度的开始时间。



单击日志语句行将显示日志的完整详细信息在右侧面板上的声明。见下面的例子。 show logs按钮位于圆圈内。





要使用GAE创建的跟踪跨度创建跟踪跨度,只需将跟踪上下文作为HTTP标头传递给GAE应用即可。

 标题名称:X-Cloud-Trace-Context 
标题格式:< trace-id> [/< span-id>] [; o =< trace-options>]

trace-id应设置为与您生成的轨迹相同。
span-id应设置为调用GAE应用程序的那个。这是GAE顶部跨度的父跨度ID。
o应该设置为1,如果你想跟踪的话,如果你不需要,则设为0.
$ b 示例:


$ b $ x-Cloud-Trace-Context:905e8445aa7843bc8bf206b13f12439c / 12345; o = 1
$ curl --headerX-Cloud-Trace-Context:4bf92f3577b34da6a3ce929d0e0e4736 / 12345; o = 1\
http://< your-app-id> .appspot.com /


When I go looking at StackDriver traces that AppEngine generates automatically, there's a log link (that never brings up any more than one line of the log, but hopefully, they're working on fixing it.)

Is there a way to tell StackDriver, when I send a trace and set of spans, what request_id to associate the trace with?

解决方案

It is supposed to be one log only since you are searching for log for one particular request. Clicking on the left side triangle will expand the log.

If you don't really need to go to logs viewer to view the log, you can use the "show logs" button on the trace detail page. By clicking on it, it will embed the log statement in between spans. The position of the log statement is determined by the log time, relative to start time of the spans.

Clicking on the log statement line will show the full details of the log statement on the right side panel. See example below. "show logs" button is in the circle.

To pair up the trace spans you created with the trace spans created by GAE, simply pass the trace context as HTTP header to the GAE app.

Header name: X-Cloud-Trace-Context
Header format: <trace-id>[/<span-id>][;o=<trace-options>]

trace-id should be set to the same as the trace you generated. span-id should be set to the one that calls into GAE app. This is the parent span id of the GAE top span. o should be set to 1 if you want to trace, 0 if you don't.

Example:

X-Cloud-Trace-Context : 905e8445aa7843bc8bf206b13f12439c/12345;o=1
$ curl --header "X-Cloud-Trace-Context:4bf92f3577b34da6a3ce929d0e0e4736/12345;o=1" \
http://<your-app-id>.appspot.com/

这篇关于如何将StackDriver跟踪链接到该事件的App Engine日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆