3

Google Cloud has a powerful tracing tool for analyzing latency of requests and RPCs. But it seems to just pick some requests that it finds deserving of traces. Sometimes that's good enough, you can just browse through existing traces. But if you are working on a performance enhancement, you want the trace on your particular query right now, you don't want to wait until it is deemed interesting.

Questions are

  • What rules intervene in deciding which queries are traced ?

  • Is there a way to ask for traces to be captured for a given URI ?

Either from within developer console, or by calling some API from within our application ? Or through some app.yaml configuration ? Or do we have to just wait and pray for the great algorithm to chose our request ?

patb
  • 1,688
  • 1
  • 17
  • 21

3 Answers3

5

You can force tracing of a HTTP request by setting the cloud trace context header properly:

$ curl -H "X-Cloud-Trace-Context: 01234567890123456789012345678901;o=1" http://<your-app>.appspot.com/<path>

01234567890123456789012345678901 (32 hex characters) is the trace id. You want to use a different one each time. o=1 enables tracing.

Use the following URL to view the trace (last part is the trace id): http://console.developer.google.com/traces/details/01234567890123456789012345678901

Sven Schoenung
  • 30,224
  • 8
  • 65
  • 70
Circy
  • 1,058
  • 11
  • 15
  • 1
    Documented here: https://cloud.google.com/trace/docs/faq#how_do_i_force_a_request_to_be_traced – ZachB Sep 14 '16 at 18:26
1

Since you're interested in particular request, why don't you use appstats? https://cloud.google.com/appengine/docs/python/tools/appstats?hl=en you can make performance enchancement, turn appstats on and deploy it to different version and have some control from appengine_config.py

I use cloud trace to get aggregate analysis, to get into more detail per request basis, I always use appstats as it contains more information.

marcadian
  • 2,608
  • 13
  • 20
1

What rules intervene in deciding which queries are traced ?

Currently there is a sampling rate that guides which request are traced. The requests are sampled at a small number of requests per second per instance.

Is there a way to ask for traces to be captured for a given URI ?

The following could possibly help depending on your scenario.

You could add a Trace Context to force the request to force tracing on the request. Trace Context is essentially a HTTP header (X-Cloud-Trace-Context)

Here is an pointer to help inject a Trace Context: https://github.com/liqianluo/gcloud-trace-java/blob/master/cloud-trace-sdk-java-core/src/main/java/com/google/cloud/trace/sdk/TraceContext.java

  • Sorry, new to stackoverflow and not sure of the nuances and subtleties of participating in this forum. But I build this tool being described above in the question. So was merely trying to help. – Sharat Shroff Feb 25 '16 at 17:23
  • @patb - Could you tell me a little more about your scenario please? I would love to understand what you are doing? My suggestion above may unblock you. – Sharat Shroff Feb 25 '16 at 18:02