Tracing libpq client: Only with PQtrace()?

Started by Sebastien Flaeschabout 2 years ago5 messagesgeneral
Jump to latest
#1Sebastien Flaesch
sebastien.flaesch@4js.com

Hello

Sorry if I missed that in the doc:

Is the PQtrace() API the only way to enable libpq client tracing?

I thought about some environment variable of client configuration setting...

Seb

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Sebastien Flaesch (#1)
Re: Tracing libpq client: Only with PQtrace()?

Hello,

On 2024-Apr-09, Sebastien Flaesch wrote:

Is the PQtrace() API the only way to enable libpq client tracing?

Yes.

Regards

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/

#3Greg Sabino Mullane
greg@turnstep.com
In reply to: Sebastien Flaesch (#1)
Re: Tracing libpq client: Only with PQtrace()?

On Tue, Apr 9, 2024 at 8:51 AM Sebastien Flaesch <sebastien.flaesch@4js.com>
wrote:

Is the PQtrace() API the only way to enable libpq client tracing?

I thought about some environment variable of client configuration
setting...

That's generally the job of the client, or more specifically, the driver
providing the interface between your program and the libpq API. Unless you
are writing at the low level yourself, in which case, you would need to
have your program detect an env and call PQtrace() as needed.

See for example
https://metacpan.org/pod/DBD::Pg#parse_trace_flag-and-parse_trace_flags

Cheers,
Greg

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Greg Sabino Mullane (#3)
Re: Tracing libpq client: Only with PQtrace()?

On 2024-Apr-09, Greg Sabino Mullane wrote:

On Tue, Apr 9, 2024 at 8:51 AM Sebastien Flaesch <sebastien.flaesch@4js.com>
wrote:

Is the PQtrace() API the only way to enable libpq client tracing?

I thought about some environment variable of client configuration
setting...

That's generally the job of the client, or more specifically, the driver
providing the interface between your program and the libpq API. Unless you
are writing at the low level yourself, in which case, you would need to
have your program detect an env and call PQtrace() as needed.

See for example
https://metacpan.org/pod/DBD::Pg#parse_trace_flag-and-parse_trace_flags

Another approach might be to use Wireshark, which has a decoder for the
Postgres FE/BE protocol.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"Pido que me den el Nobel por razones humanitarias" (Nicanor Parra)

#5Sebastien Flaesch
sebastien.flaesch@4js.com
In reply to: Greg Sabino Mullane (#3)
Re: Tracing libpq client: Only with PQtrace()?

Yep I got it, thanks for the suggestion!
Seb
________________________________
From: Greg Sabino Mullane <htamfids@gmail.com>
Sent: Tuesday, April 9, 2024 4:50 PM
To: Sebastien Flaesch <sebastien.flaesch@4js.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Tracing libpq client: Only with PQtrace()?

EXTERNAL: Do not click links or open attachments if you do not recognize the sender.

On Tue, Apr 9, 2024 at 8:51 AM Sebastien Flaesch <sebastien.flaesch@4js.com<mailto:sebastien.flaesch@4js.com>> wrote:
Is the PQtrace() API the only way to enable libpq client tracing?

I thought about some environment variable of client configuration setting...

That's generally the job of the client, or more specifically, the driver providing the interface between your program and the libpq API. Unless you are writing at the low level yourself, in which case, you would need to have your program detect an env and call PQtrace() as needed.

See for example https://metacpan.org/pod/DBD::Pg#parse_trace_flag-and-parse_trace_flags&lt;https://urldefense.com/v3/__https://metacpan.org/pod/DBD::Pg*parse_trace_flag-and-parse_trace_flags__;Iw!!I_DbfM1H!CShCRGSMCXDnZkZhChWyuMkn2offRsd-E0IeowBRQDEXbGIcpIs0rTpnx_2a79rrfeQkcbMbt2QCBlKrmHtlFw$&gt;

Cheers,
Greg