Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Query Insights query traces not linking up with application traces

Hey all

I've implemented the sqlcommenter extension with our db layer.

Everything seems to be working, analyzing the queries sent to the database I can see the /*traceparent=xxx*/ comments being added.

However, when I look at the Query Insights "End to End" view I am unable to see the linked traces.

If I search by traceid in the Trace viewer I'm able to see my traces, yet for some reason Query Insights dont seem to "connect" to the application traces.

I was able to see tags show up on queries so thats definitely working (driver name etc)

Any tips will be appreciated.. perhaps I need to enable something in our project to link Query traces to Application Traces.

1 4 1,470
4 REPLIES 4

Hi @kostyay,

If you or other users need to view the query plan or perform end-to-end tracing, you need specific IAM permissions to do so. You can create a custom role and add the necessary IAM permissions to it. Then, you can add this role to each user account that will use Query Insights to troubleshoot an issue. See Create a custom role.

The custom role needs to have the following IAM permission: cloudtrace.traces.get

Reference: Query Insights 

Thank you.

We have the roles and can view the traces.

The problem is that the query insight traces dont link up to the parent trace of our application traces.

Both show as separate traces.

Have you ever been able to figure this out?

Screenshot 2023-08-03 at 2.40.31 PM.png

I have seemingly the same issue.

As you can see from the screenshot, the traceparent= is appended to the query. I would expect that the trace view would therefore allow me to expand pg.query:contra (the highlighted row) to view trace of the query as it was executed by AlloyDB.

FYI, I ended up asking a related question on Stack Overflow https://stackoverflow.com/questions/76831794/how-get-the-traceparent-in-opentelemetry

If you have query insights enabled, you need to enable "Store application tags".

https://cloud.google.com/sql/docs/postgres/using-query-insights#enable-insights