I am trying to optimise performance in an app-engine Java app using cloud sql gen2. It would help a lot if I could trace calls to cloud sql just like I can trace RPC calls to the datastore in the stackdriver trace details. Is this somehow possible, or maybe planned? Or is the only alternative to do log.info() calls with milliseconds? Or is there some other way to add event markers for tracing / profiling?
Asked
Active
Viewed 836 times
2
-
I was going to suggest looking into Cloud Trace, but it appears that Cloud SQL is explicitly called out as unsupported: https://cloud.google.com/trace/docs/overview#how_does_stackdriver_trace_work – BrettJ Oct 13 '16 at 04:38
-
Thanks! Now the question is what is the best way to somehow profile Appengine apps using Cloud SQL? Surely there must be something better than log.info()? – cputoaster Oct 13 '16 at 12:33
-
I did find http://stackoverflow.com/questions/37952466/how-can-i-link-a-stackdriver-trace-to-the-app-engine-log-for-that-event , but I dont really see how this could work for adding SQL information to a single GAE Cloud Endpoint function. Is there a way to get the current GAE trace id so one could add spans? – cputoaster Oct 26 '16 at 08:09
1 Answers
5
There's now Google Cloud Trace for JDBC for exactly this use case.
Google Cloud Trace for JDBC is a custom JDBC driver which intercepts calls to the actual JDBC driver (e.g. Cloud SQL's) and collects and sends latency data about JDBC calls to Stackdriver Trace for visualization in the Google Cloud Console.
Here's how the trace details look like in the Google Cloud Console for an example request:
Please see the Github page for Google Cloud Trace for JDBC for more details. I'm happy to help with any issues (I'm the author).

Stefan Schmidt
- 86
- 1
- 5
-
-
Its great and works (appengine standard here). One question: In the details I see "select <...>" as the value of an sql operation. Is there a way to get more details (eg, the actual query and parameters would be very helpful...)? – cputoaster Mar 09 '17 at 09:08
-
Just in case, there is now version 0.1.1 out that does not mask errors anymore. – cputoaster Jul 19 '17 at 09:36
-
Looks great. I wish there was something similar for Go, Python, Php. – Deleplace Feb 05 '18 at 15:01