Re: Log a sample of transactions

Adrien Nayrat <adrien.nayrat@anayrat.info>

From: Adrien Nayrat <adrien.nayrat@anayrat.info>
To: "Kuroda, Hayato" <kuroda.hayato@jp.fujitsu.com>, "'pgsql-hackers@lists.postgresql.org'" <pgsql-hackers@lists.postgresql.org>
Date: 2019-02-03T11:23:00Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Tweak docs for log_statement_sample_rate

On 1/28/19 2:53 AM, Kuroda, Hayato wrote:
> BTW, I give you a suggestion about a test.
> This parameter enables users to log statements randomly, hence adding some tests is very difficult.
> Perhaps Only three cases are available:
> 
> * When log_transaction_sample_rate is set to 1, all statements are logged.
> * When the parameter is set to 0, they are never logged.
> * When the parameter change to 0 inside the transaction, logging is immediately stopped.

I agree we should add tests, my main problem is log output contains duration
information:

postgres=# select 1;
LOG:  duration: 0.539 ms  statement: select 1;

I did not find any test for log_min_duration that could help me. LCOV indicate
there is no tests on this part (look check_log_duration()):
https://coverage.postgresql.org/src/backend/tcop/postgres.c.gcov.html

I will look how to test this properly with test infrastructure. Maybe a simple
regex to remove duration part will be enough.