Re: POC: Extension for adding distributed tracing - pg_tracing - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: POC: Extension for adding distributed tracing - pg_tracing
Date
Msg-id CAGRY4nzV1vK5C9jO5rD8Em5wgvENfiHj2YcGHDKC0xLdw5PgPA@mail.gmail.com
Whole thread Raw
In response to Re: POC: Extension for adding distributed tracing - pg_tracing  (Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>)
Responses Re: POC: Extension for adding distributed tracing - pg_tracing
List pgsql-hackers
Hi all

Just saw this thread.

I cooked up a PoC distributed tracing support in Pg years ago as part of the 2ndQuadrant BDR project.

I used GUCs to set the `opentelemtery_trace_id` and `opentelemetry_span_id`. These can be sent as protocol-level messages by the client driver if the client driver has native trace integration enabled, in which case the user doesn't need to see or care. And for other drivers, the application can use `SET` or `SET LOCAL` to assign them.

This approach avoids the need to rewrite SQL or give special meaning to SQL comments.

Within the server IIRC I used the existing postgres resource owner and memory context stacks to maintain some internal nested traces.

My implementation used the C++ opentelemetry client library to emit traces, so it was never going to be able to land in core. But IIRC the current BDR/PGD folks are now using an OpenTelemetry sidecar process instead. I think they send it UDP packets to emit metrics and events. Petr or Markus might be able to tell you more about how they're doing that.

I'd love to see OpenTelemetry integration in Pg.

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: unconstify()/unvolatize() vs g++/clang++
Next
From: Greg Sabino Mullane
Date:
Subject: Adding comments to help understand psql hidden queries