Re: POC: Extension for adding distributed tracing - pg_tracing
От | Anthonin Bonnefoy |
---|---|
Тема | Re: POC: Extension for adding distributed tracing - pg_tracing |
Дата | |
Msg-id | CAO6_XqpD8CfSpmKvc6bhyyTtMrBrmN13+8SRc--QWURi4NBOEg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: POC: Extension for adding distributed tracing - pg_tracing (Aleksander Alekseev <aleksander@timescale.com>) |
Ответы |
Re: POC: Extension for adding distributed tracing - pg_tracing
Re: POC: Extension for adding distributed tracing - pg_tracing |
Список | pgsql-hackers |
Hi, > This approach avoids the need to rewrite SQL or give special meaning to SQL comments. SQLCommenter already has a good amount of support and is referenced in opentelemetry https://github.com/open-telemetry/opentelemetry-sqlcommenter So the goal was more to leverage the existing trace propagation systems as much as possible. > 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. Emitting `SET` and `SET LOCAL` for every traced statement sounds more disruptive and expensive than relying on SQLCommenter. When not using `SET LOCAL`, the variables also need to be cleared. This will also introduce a lot of headaches as the `SET` themselves could be traced and generate spans when tracing utility statements is already tricky enough. > 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. I would be curious to hear more about this. I didn't want to be tied to a specific protocol (I've only seen gRPC and http support on latest opentelemetry collectors) and I fear that relying on Postgres sending traces would lower the chance of having this supported on managed Postgres solutions (like RDS and CloudSQL). > By queries you mean particular queries, not transactions? And since > they have an assigned ID it means that the query is already executing > and we want to enable the tracking in another session, right? I think that was the idea. The query identifier generated for a specific statement is stable so we could have a GUC variable with a list of query id and only queries matching the provided query ids would be sampled. This would make it easier to generate traces for a specific query within a session. On Tue, Jan 2, 2024 at 1:14 PM Aleksander Alekseev <aleksander@timescale.com> wrote: > > Hi, > > > Overall solution looks good for me except SQL Commenter - query instrumentation > > with SQL comments is often not possible on production systems. Instead > > the very often requested feature is to enable tracing for a given single query ID, > > or several (very limited number of) queries by IDs. It could be done by adding > > SQL function to add and remove query ID into a list (even array would do) > > stored in top tracing context. > > Not 100% sure if I follow. > > By queries you mean particular queries, not transactions? And since > they have an assigned ID it means that the query is already executing > and we want to enable the tracking in another session, right? If this > is the case I would argue that enabling/disabling tracing for an > _already_ running query (or transaction) would be way too complicated. > > I wouldn't mind enabling/disabling tracing for the current session > and/or a given session ID. In the latter case it can have an effect > only for the new transactions. This however could be implemented > separately from the proposed patchset. I suggest keeping the scope > small. > > -- > Best regards, > Aleksander Alekseev
В списке pgsql-hackers по дате отправления: