Pgx: opentracing/tracing?

Created on 28 Jan 2019  路  5Comments  路  Source: jackc/pgx

Hello,
I can't figure out how to do tracing. the conn.OnNotice is might be good for logging but it cant be used with tracers because it does not give you the context.

thanks

Most helpful comment

The recently released v4 Logger interface now includes a context.Context.

All 5 comments

OnNotice would only trigger when the server sends a notice so I don't think that would do what you want. In addition, I don't think there is a clean way of reliably getting a context to that method (it can be called from anywhere messages are received from the PG server).

Have you looked at implementing the Logger interface?

i understand.

I have not got a chance to play with this library because I need tracing support and I am using the stdlib.

does the logger interface give you the context?

edit: it seems like the logger does not get the context.Context.
since i am not familiar with this library, can you add context to the caller, please?

No, but you can set the logger per request and your custom logger could contain the context. Somewhat awkward, but possible anyway.

Adding context to logger would be a good change, but unfortunately it would be a breaking change. Might be good for v4.

it does not have to be a breaking change. you can add context to data map[string]interface{} so we can retrieve it like data["context"].(context.Context)

The recently released v4 Logger interface now includes a context.Context.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kellabyte picture kellabyte  路  11Comments

zargex picture zargex  路  8Comments

kokizzu picture kokizzu  路  6Comments

bernhardreiter picture bernhardreiter  路  7Comments

Zamiell picture Zamiell  路  10Comments