You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The tracelog packlage (github.com/jackc/pgx/v5/tracelog") uses "time" as a label to print the time used to process. This however causes conflicts with other logging systems that will use "time" as a label to mean timestamp of log produced. This causes log ingestors to fail parsing the JSON as there is a duplicate key.
To Reproduce
Steps to reproduce the behavior:
Use github.com/jackc/pgx/v5/tracelog and github.com/jackc/pgx-zerolog and a logger configured roughly like so:
The tracelog package should avoid using generic labels like "time", etc as those can likely collide with other labels. I'd suggest adding a prefix (perhaps configurable) so that it will be logged like "pgx.QueryTime", for all tracelog labels.
I don't think I want to change the default name. It's been called "time" for as long as there has been logging in pgx. But I'm open to making the name of the time/duration field configurable. Presumably an extra field on tracelog.TraceLog should do it. I don't think any other fields should collide.
Sounds good to me. There is another alternative which is to change the zerologadapter (I've done that to test as a quick fix) and prepend the prefix of choice in there:
Describe the bug
The tracelog packlage (github.com/jackc/pgx/v5/tracelog") uses "time" as a label to print the time used to process. This however causes conflicts with other logging systems that will use "time" as a label to mean timestamp of log produced. This causes log ingestors to fail parsing the JSON as there is a duplicate key.
To Reproduce
Steps to reproduce the behavior:
Use
github.com/jackc/pgx/v5/tracelog
andgithub.com/jackc/pgx-zerolog
and a logger configured roughly like so:and configure pgx pool like so:
Use the pgClient to run some queries and observe the logs:
Notice the duplicate "time" entry,.
Expected behavior
The tracelog package should avoid using generic labels like "time", etc as those can likely collide with other labels. I'd suggest adding a prefix (perhaps configurable) so that it will be logged like "pgx.QueryTime", for all tracelog labels.
Version
$ go version
-> 1.22github.com/jackc/pgx/v5 v5.6.0
github.com/jackc/pgx-zerolog v0.0.0-20230315001418-f978528409eb
The text was updated successfully, but these errors were encountered: