How can I link a StackDriver trace to the App Engine log for that event?

≡放荡痞女 提交于 2019-12-08 00:53:40

问题


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?


回答1:


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/


来源:https://stackoverflow.com/questions/37952466/how-can-i-link-a-stackdriver-trace-to-the-app-engine-log-for-that-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!