google / sqlcommenter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Traces not showing with Go Implementation in Query Insights

kostyay opened this issue · comments

Hey
I've implemented this in my code.
I can see that traceparent is added to each query, unfortunately though the traces are not being linked up to my application traces. The query insights "end to end" view only shows the query breakdown without any of the application traces.
Perhaps tracespan is missing?
Any ideas how to debug this?

Hi @kostyay,

traceparent contains the trace-id and parent span-id, which is what is needed to link the query plans with application traces.

Now, to debug we can take a look at few things:

  1. Can you check in your application layer what is the trace-id(part of traceparent) and is it same as the trace-id populated as part of query ?
  2. Is the application exporting traces to GCP by using OpenTelemetry library ?

Hey
Thanks for the reply.
Yes the traceids match and the application is reporting the traces using opentelemetry and they show in the Trace view of the console.
However Query Insights traces don't link up with the application traces.
The trace id and span that shows for the query is not one I recognize (I added verbose logging to our app printing the trace ids and the ones in QI were never printed)

Hey ... which database are you using MySQL or PG?

Postgres 14.
Do I need to enable any extensions for this to work (besides Query Insights)?

Postgres 14.

Thanks. Will look into this.

Do I need to enable any extensions for this to work (besides Query Insights)?

No, Query Insights extension should be enough

Just as a reference it doesn't work with Postgres 11 too.
We have a support ticket with Google about this, if you want some links/trace ids I can email them to you

@kostyay

I can see that traceparent is added to each query

Can you please give more information on how you checked that traceparent is populated for each query i.e.

  1. By using application logs or database logs ? OR
  2. traces from Query Insights UI ?
  1. I enabled debug logging in pgx driver that forces it to print all the queries before its running and saw /traceparent=xxx/ on the queries
  2. I also saw them in the postgres.log file in the CloudSQL instance.