Re: POC: Extension for adding distributed tracing - pg_tracing

From: Craig Ringer <craig(dot)ringer(at)enterprisedb(dot)com>
To: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
Cc: Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Nikita Malakhov <hukutoc(at)gmail(dot)com>
Subject: Re: POC: Extension for adding distributed tracing - pg_tracing
Date: 2023-12-11 21:51:17
Message-ID: CAGRY4nzV1vK5C9jO5rD8Em5wgvENfiHj2YcGHDKC0xLdw5PgPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Sabino Mullane 2023-12-11 21:53:01 Adding comments to help understand psql hidden queries
Previous Message Thomas Munro 2023-12-11 20:49:34 Re: unconstify()/unvolatize() vs g++/clang++